首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web前端 >

spring调整struts2配置

2012-09-16 
spring整合struts2配置web.xml中配置spring配置文件的地址和context启动类context-paramparam-namecon

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的引用就可以了

热点排行