Tomcat6下的Struts2.1与Spring3.03整合
1、从Struts及Spring库内复制以下文件到工程库(只引入必要的库),全部复制进来时往往会导致框架启动失败。

?2、在Web.xml内加入
<context-param>
<param-name>contextConfigLocation</param-name>
<!-- 如果有多个bean配置文件,有逗号分隔开 -->
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>
<listener>
<!-- 注册Spring的监听器,在程序启动时自动运行。(适合Servlet2.5及以上,早期版本使用servlet配置) -->
<listener-class> org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
3、注意Struts2的配置文件(struts.xml)内指定action时,class指向Spring的配置文件(applicationContext.xml)内的Bean的ID。如:struts.xml片断
<action name="login" ref="userService"/>
</bean>