把action交给spring管理
参考链接:
1. http://www.blogjava.net/zJun/archive/2007/01/08/92417.html
2. http://love398146779.iteye.com/blog/909723
3. http://blog.sina.com.cn/s/blog_6848c4440100siua.html
一、spring和struts1.x
spring的一个jar包: spring-webmvc-struts.jar
<plug-in/>将struts的处理转给Spring了,由Spring IOC控制调用Struts中的组件,这样你就需要在Spring那个applicationContext.xml中加入Action相应的bean类
1.web.xml里配置struts-config.xml(struts1.x配置文件),Tomcat启动加载该文件。
<action name="treeForm" path="/tree" scope="request" parameter="actions" type="org.springframework.web.struts.DelegatingActionProxy"> <forward name="select" path="/platform/common/treeSelect.jsp" /> <forward name="defeat" path="/common/error.jsp" /> </action> <plug-in className="org.springframework.web.struts.ContextLoaderPlugIn"> <set-property property="contextConfigLocation" value="/WEB-INF/classes/spring/core/applicationContext-action.xml" /> </plug-in> 注意:此处的plug-in也可以注释掉,直接在applicationContext.xml里加载applicationContext-action.xml也可以
2.applicationContext-action.xml
<bean name="/frameTest" class="com.lenovo.example.web.action.FrameTestAction"> <property name="frameTestService" ref="frameTestService" /> </bean> <bean name="/flowTest" class="com.lenovo.example.web.action.FlowTestAction"> <property name="flowTestService" ref="flowTestService" /> <property name="flowService" ref="engineflowService"/> </bean>
二、spring和struts2.x
通过struts2.x里的一个jar包,启动自动将struts2.x控制权给spring
spring的一个jar包: struts2-spring-plugin-2.1.8.1.jar