spring 在web.xml 里面如何使用多个xml配置文件
来源:互联网 发布:画册设计软件 编辑:程序博客网 时间:2024/05/24 04:09
在web.xml中定义 contextConfigLocation参数.spring会使用这个参数加载.所有逗号分割的xml.如果没有这个参数,spring默认加载web-inf/applicationContext.xml文件.
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring-config.xml,classpath:spring-cxf.xml,classpath:spring-quartz.xml
</param-value>
</context-param>
原理:
Spring 提供ServletContextListener 的一个实现类ContextLoaderListener ,该类可以作
为listener 使用,它会在创建时自动查找WEB-INF/ 下的applicationContext.xrnl 文件。因
此,如果只有一个配置文件,并且文件名为applicationContext.xml ,则只需在web.xml
文件中增加如下代码即可:
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
如果有多个配置文件需要载入,则考虑使用<context-para即元素来确定配置文件的
文件名。由于ContextLoaderListener加载时,会查找名为contextConfigLocation的参数。
因此,配置context-param时参数名字应该是contextConfigLocation。
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring-config.xml,classpath:spring-cxf.xml,classpath:spring-quartz.xml
</param-value>
</context-param>
原理:
Spring 提供ServletContextListener 的一个实现类ContextLoaderListener ,该类可以作
为listener 使用,它会在创建时自动查找WEB-INF/ 下的applicationContext.xrnl 文件。因
此,如果只有一个配置文件,并且文件名为applicationContext.xml ,则只需在web.xml
文件中增加如下代码即可:
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
如果有多个配置文件需要载入,则考虑使用<context-para即元素来确定配置文件的
文件名。由于ContextLoaderListener加载时,会查找名为contextConfigLocation的参数。
因此,配置context-param时参数名字应该是contextConfigLocation。
阅读全文
0 0
- spring 在web.xml 里面如何使用多个xml配置文件
- spring 在web.xml 里面如何使用多个xml配置文件
- spring如何使用多个xml配置文件
- spring如何使用多个xml配置文件
- spring如何使用多个xml配置文件
- spring如何使用多个xml配置文件
- spring如何使用多个xml配置文件
- spring如何使用多个xml配置文件
- spring如何使用多个xml配置文件
- 多个spring配置文件时在web.xml中的写法
- spring多个配置文件web.xml写法
- web.xml加载多个spring配置文件
- 如何使用多个Spring的xml配置文件
- Spring使用多个xml配置文件
- 如何 在Spring MVC中 使用多个Spring和MyBatis的xml配置文件(多模块配置)
- Struts多个配置文件,如何配置web.xml
- 如何使用多个Spring的xml配置文件(多模块配置)
- 如何使用多个Spring的xml配置文件(多模块配置)
- 前端之css之单位
- 关于使用讯搜(xunsearch)过程中遇到的坑
- 扩屏双显示器一个清晰,另一个模糊的解决办法
- ASP.NET Core:部署项目到Ubuntu Server
- 用do-while语句编程实现累加功能
- spring 在web.xml 里面如何使用多个xml配置文件
- C#创建List存放匿名对象、遍历List、泛值取值
- 微信小程序 —— 上传文件到服务器(例:上传图片到服务器)
- li元素按中文首字母排序
- sphinx中文检索引擎coreseek+php+mysql搭建
- java super()与this()问题
- angularjs 猜大小
- Lintcode67 Binary Tree Inorder Traversal solution 题解
- 发个模板引擎