前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >struts2中action的class属性值意义

struts2中action的class属性值意义

作者头像
ydymz
发布2018-09-10 15:41:37
1.2K0
发布2018-09-10 15:41:37
举报
文章被收录于专栏:lgp20151222

整合了spring就不同了,orz

struts2单独使用时action由struts2自己负责创建;与spring集成时,action实例由spring负责创建(依赖注入)。这导致在两种情况下struts.xml配置文件的略微差异。

假如:LoginAction在包com.csu.action中。

1. struts2单独使用时,action的class属性为LoginAction的全路径名,如下:

<action name="login" class="com.csu.action.LoginAction">

           <result name="studentSuccess">

                /student/studentindex.jsp

           </result>

2. struts2与spring集成时,class属性是spring的applicationContext.xml中配置的bean的id属性值。

//struts.xml

<action name="login" class="LoginAction">

           <result name="studentSuccess">

                /student/studentindex.jsp

           </result>

//applicationContext.xml    或者在spring相应的配置文件中

<bean id="LoginAction" class="com.csu.action.LoginAction" />

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2018-01-22 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档