让Spring管理struts中的action,可以在struts.xml中增加配置
<constant name="struts.objectFactory" value="spring" />
并且在web.xml中定义spring监听器
由于org.springframework.web.context.ContextLoaderListener是在spring-web.jar包中,所以需将WEB-INF/lib中加入spring-web.jar包
<constant name="struts.objectFactory" value="spring" />
并且在web.xml中定义spring监听器
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
由于org.springframework.web.context.ContextLoaderListener是在spring-web.jar包中,所以需将WEB-INF/lib中加入spring-web.jar包