The previous article has already talked about the Spring2.5 configuration, this chapter is about how to integrate struts on the Spring2.5.
Third, integrated Struts2 in Spring2.5
3.1 Modify the existing web.xml.
Add the following two paragraph code:
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.str uts2.dispatcher.filterdispatcher</filter-class>
</filter>
<filter-mapping>
<f ilter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapp Ing>
3.2 Complete Web.xml Code
<?xml version= "1.0" encoding= "UTF-8"?> <web-app id= "webapp_id" version= "2.4" xmlns= "Http://java.sun.com/xml" /ns/j2ee "xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance "xsi:schemalocation=" http://java.sun.com/xml/ns/
Java http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd "> <!--######################################--> <!--########## Struts2 ##################--> <!--######################################--> & lt;! * STRUTS2 's main filter, responsible for four aspects of the function: * (1) Perform actions * (2) Clear Actioncontext * (3) Maintain static content * (4) Clear re The interceptors of the Xwork in the Quest lifecycle * Note: The filter should filter all request URLs.
Generally set to/* ************--> <filter> <filter-name>struts2</filter-name> <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class> </filter> &L t;! --######################################--> <!--########## Spring2 ##################--> <!--######################################--> <!--* [<context-param>& Lt;/context-param] => is used to set the environment parameters of the Web site * [<param-name></param-name>] (child element) => the name of the parameter to specify * [ <param-value></param-value>] (child element) => is used to set the parameter value * ************ * Load Spring's configuration file from the Classpath, multiple profiles can be comma-and Space distinction * CLASSPATH: keyword refers to the class path loading ********************--> <context-param> <param-name& Gt;contextconfiglocation</param-name> <param-value>classpath:applicationcontext*.xml</ Param-value> </context-param> <!--* [<listener></listener>]=> used to set the listening interface * [<listener-class></listener-class>] (child element) => define Listener class name * ******* * Responsible for starting the spring listener * It takes the context parameter at the reference to the spring configuration file address * Specify Spring-provided Conte Xtloaderlistener Web Container Listener, * The listener runs automatically when the Web container starts and gets the spring configuration file based on the Contextloaderlistener parameter * and starts the SprinG container. --> <listener> <listener-class> org.springframework.web.context.c Ontextloaderlistener </listener-class> </listener> <filter-mapping> <fi Lter-name>struts2</filter-name> <url-pattern>/*</url-pattern> </FILTER-MAPPING&G
T <display-name>miziStudy</display-name> <welcome-file-list> <welcome-file>index.html& Lt;/welcome-file> <welcome-file>index.htm</welcome-file> <welcome-file>index.jsp< ;/welcome-file> <welcome-file>default.html</welcome-file> <welcome-file>default.htm </welcome-file> <welcome-file>default.jsp</welcome-file> </welcome-file-list> </ Web-app>