ssh框架配置时,多spring,strut2配置文件配置,方便大型项目团队开发

本文详细介绍了如何在SSH框架中进行多文件配置,包括web.xml文件、Spring容器配置和Struts2配置文件的管理。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

     由于自己在公司做struts2+spring+mybatis开发,里面对配置文件的管理特别好,自己开发的模块自己写配置文件,所以今天晚上就对ssh框架的多文件配置做了一下实践。

    web.xml文件如下:

  

<context-param>
  <param-name>contextConfigLocation</param-name> --必须为这个,这是spring容器查找的依据
  <param-value>classpath:applicationContext.xml,/WEB-INF/customization/*.xml</param-value>  --多个spring配置文件以,分隔
 </context-param>

 

 <listener>
  <listener-class>
   org.springframework.web.context.ContextLoaderListener   --spring加载配置文件的类
  </listener-class>
 </listener>


 <filter>
  <filter-name>struts2</filter-name>
  <filter-class>
   org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
  </filter-class>
  
  <init-param>
  <param-name>config</param-name>  --多个struts2配置文件的标记,必须为这个
  <param-value>
  struts-default.xml,struts-plugin.xml,   --上面这两个必须加上,否则会报No mapping found for dependency[type=com.opensymphony.xwork2.ObjectFactory, name='default']
  /WEB-INF/customization/*.xml --自己定义的多个strut2配置文件
  </param-value>
  </init-param>

 </filter>

 <filter-mapping>
  <filter-name>struts2</filter-name>
  <url-pattern>/*</url-pattern>
 </filter-mapping>

 

 

当然spring还可以在applicationContext.xml中通过<import resource>来引入

在strut2中可以通过<include file='''>来引入

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值