当前位置: 代码迷 >> Web前端 >> spring调整struts2配置
  详细解决方案

spring调整struts2配置

热度:86   发布时间:2012-09-16 17:33:17.0
spring整合struts2配置
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的引用就可以了
  相关解决方案