struts整合spring

编写接口,别写接口的实现类,接着写action的代码,jsp里面的提交form里面的action怎么写具体看

 

jsp页面里面的action要写struts.xml里面的action名字。

struts.xml里面的每个action里面的class="loginAction"这里的loginAction不再是以前的真正的类的映射!

因为要交给spring管理,所以这里的loginAction 必须 要与 applicationContext.xml 中的

<bean id="loginAction" class="org.lmxzz.struts2.action.LoginAction" scope="prototype">

的 id="loginAction" 保持一致,这里的class="org.lmxzz.struts2.action.LoginAction"就是真正的类的映射,这样写,就表明了struts.xml中的loginAction 已交给 spring来进行管理。scope="prototype" 这里和以前的struts1.x整合spring的时候不一样,因为strust1.x对action的管理是单例模式。

 

配置web.xml的时候

<listener>
 <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

它为服务器添加了一个监听器,这样也使的struts2 与 spring 结合起来。如果没有这句话,服务器是启动不了的。

转载于:https://www.cnblogs.com/imhurley/archive/2012/06/03/2532399.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值