让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包
本文介绍如何通过在struts.xml中配置<constant name=struts.objectFactory value=spring/>以及在web.xml中定义spring监听器来让Spring管理Struts中的Action。此外,还需要在项目的WEB-INF/lib目录下引入spring-web.jar包。
5792

被折叠的 条评论
为什么被折叠?



