測試版本:Struts2.3.4 、Spring3.2
1、確保你的struts2-spring插件jar包已經添加
2、將如下代碼復制到web.xml中
<SPAN > </SPAN><context-param>
<SPAN > </SPAN><param-name>contextConfigLocation</param-name>
<SPAN > </SPAN> <param-value>/WEB-INF/classes/beans.xml</param-value> <!-- 此處存放spring的配置文件-->
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
3、在struts.xml中指定objectFactory
<constant name="struts.objectFactory" value="org.apache.struts2.spring.StrutsSpringObjectFactory" />