1. Add the struts2 package
2. Configure the struts2 filter in Web. xml
<filter><filter-name>struts2</filter-name><filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class></filter><filter-mapping><filter-name>struts2</filter-name><url-pattern>/*</url-pattern></filter-mapping>
3. Write struts. xml and test the application to verify that the struts configuration is correct.
<package name="h" extends="struts-default"> <action name="login" class="org.ymm.actions.LoginAction" method="mlogin"><result name="success" type="redirect">login.jsp</result><result name="fail">fail.jsp</result></action></package>
4. If struts is OK, add the spring support package and configure the listener contextloaderlistener.
(Let spring be loaded before struts and manage struts actions later)
Note: struts2-spring-plugin-2.3.3.jar must be added to this pack
<context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:beans.xml</param-value> </context-param> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener>
The loading sequence of Web. XML is context-Param.
-> Listener-> filter-> servlet (because listener is prior to filter, use listener to start spring)
See: http://blog.csdn.net/without0815/article/details/7689661
In the struts2 configuration file, add
<Constant name = "struts. objectfactory" value = "Spring"> </constant> attribute
5. Compile beans. xml beans, such as beans that manage actions in sturts:
<bean id="spring" class="org.ymm.actions.LoginAction">.......</bean>