Struts2 与 Spring的整合,是通过struts2-spring-plugin-2.0.11.jar插件包实现的:
一、引用插件包struts2-spring-plugin-2.0.11.jar
二、配置web.xml
(1) 默认是读applicationcontext.xml
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
(2)如果是让spring初始化自定义的配置文件,则可以如下配置,
<!-- Context Configuration locations for Spring XML files -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring-web.xml</param-value>
</context-param>
如此,struts2和spring实现整合