web.xml中配置spring配置文件的地址和context启动类
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/**/spring*.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
然后在spring*.xml文件中配置bean管理
这里bean用自动扫描的方式配置
<!-- 自动扫描bean -->
<context:component-scan base-package="com.huawei"
use-default-filters="false">
<context:include-filter type="regex"
expression="com.huawei.struts.*Action" />
<!--
<context:include-filter type="regex"
expression="com.huawei.service.impl.*ServiceImpl" />-->
</context:component-scan>
在struts的action的配置中class改为spring 管理bean的引用就可以了