Spring :监听器ContextLoaderListener的作用
来源:互联网 发布:企业汉字做域名的品牌 编辑:程序博客网 时间:2024/05/18 20:07
转载:http://blog.csdn.net/java_wliang/article/details/18044507
ApplicationContext.xml的时候没有配置监听器,在web.ml中配置如下:
但是在Tomcat启动的时候日志中显示如下:
信息: No Spring WebApplicationInitializer types detected on classpath
也就是Spring没有配置文件,导致后面访问的时候发生错误。
原因:后来查找之下是发现没有在web.xml中使用ContextLoaderListener监听器。设置监听器
启动tomcat之后日志如下:
2014-1-9 16:42:24 org.apache.catalina.core.ApplicationContext log
信息: Initializing Spring root WebApplicationContext
Spring提供ServletContentListener的一个实现类ContextLoaderListener监听器,该类可以作为Listener使用,在启动Tomcat
容器的时候,该类的作用就是自动装载ApplicationContext的配置信息,如果没有设置contextConfigLocation的初始参数则会
使用默认参数WEB-INF路径下的application.xml文件。如果需要自定义读取多个配置文件或者修改默认路径,则可以在web.xml
中设置:
ContextLoaderListener会读取这些XML文件并产生 WebApplicationContext对象,然后将这个对象放置在ServletContext的属性
里,这样我们只要可以得到Servlet就可 以得到WebApplicationContext对象,并利用这个对象访问spring 容器管理的bean。
初始成功之后显示如下
信息: Initializing Spring root WebApplicationContext
- Spring :监听器ContextLoaderListener的作用
- Spring监听器ContextLoaderListener的作用
- Spring监听器ContextLoaderListener的作用
- Spring监听器ContextLoaderListener的作用
- Spring :监听器ContextLoaderListener的作用
- 监听器ContextLoaderListener的作用
- 监听器的作用-ContextLoaderListener
- [Spring]web.xml中配置ContextLoaderListener监听器的作用
- [Spring]web.xml中配置ContextLoaderListener监听器的作用
- 详解ContextLoaderListener监听器的作用
- spring项目中监听器作用-ContextLoaderListener
- spring项目中监听器作用-ContextLoaderListener
- Spring——监听器ContextLoaderListener作用
- spring监听器ContextLoaderListener的疑问
- spring ContextLoaderListener的作用
- [Spring] ContextLoaderListener的作用
- spring ContextLoaderListener的作用
- spring ContextLoaderListener的作用
- Java 8 Stream – Read a file line by line
- QT:QMessageBox的简单使用
- 身份证号码验证Util
- 生成带参数的二维码接口实例
- 开源之于VMware的重要性
- Spring :监听器ContextLoaderListener的作用
- RxJava 官方文档中文翻译
- Unity Socket TCP
- vue+webpack项目中px2rem的例子
- Activity是如何加载布局文件的?
- [LeetCode] 103. Binary Tree Zigzag Level Order Traversal
- Let's Encrypt实现
- Ubuntu系统关机时将网卡工作模式由千兆自动切换至百兆非自适应
- 清华梦的粉碎—写给清华大学的退学申请(转自王垠Blog)