web.xml配置文件中ContextLoaderListener的作用
来源:互联网 发布:桑拿软件 编辑:程序博客网 时间:2024/05/22 15:38
在搭建ssm框架的时候,在web.xml配置文件中配置监听器listener,它的作用是在启动web容器时,自动装配Spring的applicationContext.xml的配置信息。ContextLoaderListener继承ContextLoader类,所以加载applicationContext.xml的配置文件过程中由ContextLoader类来完成
<listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class></listener>
那么,在配置applicationContext.xml的过程中,如果在web.xml中不写任何参数配置信息,默认的路径是/WEB-INF/applicationContext.xml,在WEB-INF目录下创建的xml文件的名称必须是applicationContext.xml。
- 如果是要自定义文件名可以在web.xml里加入contextConfigLocation这个context参数
<context-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/classes/applicationContext-*.xml</param-value></context-param>
在param-value里指定相应的xml文件名,如果有多个xml文件,可以使用“,”号分隔。如上面的applicationContext-*.xml采用通配符,比如这那个目录下有applicationContext-mybatis.xml,applicationContext-hessian.xml,applicationContext-logic.xml等文件,都会一同被载入。
- 如果applicationContext.xml文件没有在/WEB-INF/下,或文件名不一致,或存在多个Spring配置文件,在web.xml文件中根据下面代码修改
<context-param> <param-name>contextConfigLocation</param-name> <param-value> classpath*:applicationContext-*.xml, /WEB-INF/classes/applicationContext-*.xml <param-value> </context-param>
阅读全文
0 0
- web.xml配置文件中ContextLoaderListener的作用
- JavaEE 下面使用Spring 时 web.xml 中ContextLoaderListener的作用及配置,多个配置文件时contextConfigLocation的作用
- [Spring]web.xml中配置ContextLoaderListener监听器的作用
- [Spring]web.xml中配置ContextLoaderListener监听器的作用
- web.xml文件中配置spring的ContextLoaderListener后报错
- spring项目中,web.xml中的 ContextLoaderListener监听器的原理
- web.xml中DispatcherServlet和ContextLoaderListener的区别
- web.xml中spring如何通过ContextLoaderListener初始化的
- spring中ContextLoaderListener的作用
- Web项目中web.xml配置文件context-param作用
- org.springframework.web.context.ContextLoaderListener的作用
- Struts配置文件详解,web.xml以及struts-cofig.xml,以及struts-cofig.xml中各个标签的作用。
- Struts配置文件详解,web.xml以及struts-cofig.xml,以及struts-cofig.xml中各个标签的作用
- Java Web中web.xml的作用
- web.xml(ContextLoaderListener)
- 唯爱小粽子:Spring中ContextLoaderListener的作用
- SpringMVC中web.xml的常用配置文件
- springMVC中contextLoaderListener作用
- ARM架构基础知识
- 作业:简化的插入排序
- 正则表达式: NFA引擎匹配原理
- redis主从数据复制实现原理与搭建
- 转换注释,从文件里哦
- web.xml配置文件中ContextLoaderListener的作用
- fzu2082(树链剖分)
- mysql 表B字段替换表A字段
- nginx的五种负载算法模式
- Pycaffe-简单测试caffe模型的分类效果和运行速度
- PHP常量
- 虚拟内存和物理内存
- Hbase与Mapreduce集成的案例
- 上拉加载更多和下拉刷新