struts+spring整合

 struts+spring整合有3种方式,通过查阅资料得知,将servlet action 委托给spring来管理的这种方式优势最为显著.本次struts+spring整合测试就是采用委托的方法。   实施步聚:   首先在struts-config.xml文件中注册spring插件,如下所示。 <plug-in className="org.springframework.web.struts.ContextLoaderPlugIn"> <set-property property="contextConfigLocation" value="/WEB-INF/applicationContext.xml" /> </plug-in> <script>render_code(); </script>   其次将所有action标签中type属性设为org.springframework.web.struts.DelegatingActionProxy 也就是将action委托给了spring 因而在spring上下文applicationContext.xml中配置一个于action标签path属性对应的bean(也就是bean的name值等于action的path值),如: struts-config.xml代码片段 代码 ...... action-mappings> <action attribute="userForm" input="/user.jsp" name="userForm" path="/user" scope="request" type="org.springframework.web.struts.DelegatingActionProxy" validate="false" /> </action-mappings> ..... <script>render_code(); </script> applicationContext.xml代码片段 代码 ...... <bean name="/user" class="com.wiley.struts.action.UserAction" singleton="false" > <property name="manage"> <ref bean="manage" /> </property> </bean> ...... <script>render_code(); </script>   到此基本的配置工作完成了   在测试的过程中遇到servlet action无效,但控制台没有任何的提示,翻遍整个网络,e文看得是一知半解,中文资料很少,对我来说有价值的更少,将log4j增加上去后再次测试,原来是ContextLoaderPlugIn没有找到。在使用MyEclipse搭建spring环境时,请务必将spring-web也导入。   最后将spring-web加入后测试成功。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值