Spring and STRUTS2 integration, struts.xml in SRC directory
1. Configure the Listener in Web. xml
Xml
<!--configuring spring's listener for initializing the ApplicationContext -<Listener> <Listener-class>Org.springframework.web.context.ContextLoaderListener</Listener-class></Listener><Context-param> <Param-name>Contextconfiglocation</Param-name> <Param-value>Classpath:applicationcontext*.xml</Param-value></Context-param><!--Configuring the primary filter for STRUTS2 -<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>
2. Copy a jar package for integration (a plugin for spring integration)
Struts-2.1.8.1/lib/struts2-spring-plugin-2.1.8.1.jar
3, Description:
1, specify @Controller and @Scope ("prototype") when writing action
2, when configuring the action in Struts.xml, write the Bean's name in the class attribute
Spring and Spring MVC integration
Xml
<Listener> <Listener-class>Org.springframework.web.context.ContextLoaderListener</Listener-class></Listener><Context-param> <Param-name>Contextconfiglocation</Param-name> <Param-value>Classpath:beans.xml</Param-value></Context-param>
<servlet> <Servlet-name>Springmvc</Servlet-name> <Servlet-class>Org.springframework.web.servlet.DispatcherServlet</Servlet-class> <Init-param> <Param-name>Contextconfiglocation</Param-name> <Param-value>Classpath:springmvc.xml</Param-value> </Init-param></servlet><servlet-mapping> <Servlet-name>Springmvc</Servlet-name> <!--do not use/*, using *.xxx - <Url-pattern>*.do</Url-pattern></servlet-mapping>
Spring and STRUTS2 Integration vs Spring and Spring MVC integration