【随笔】Spring中的监听器ContextLoaderListener
来源:互联网 发布:gtp软件手机版 编辑:程序博客网 时间:2024/06/02 19:29
ContextLoaderListener监听器的作用就是启动Web容器时,自动装配ApplicationContext的配置信息;源码如下
package org.springframework.web.context;import javax.servlet.ServletContextEvent;import javax.servlet.ServletContextListener;public class ContextLoaderListener extends ContextLoader implements ServletContextListener{ public ContextLoaderListener() { } public ContextLoaderListener(WebApplicationContext context) { super(context); } public void contextInitialized(ServletContextEvent event) { initWebApplicationContext(event.getServletContext()); } public void contextDestroyed(ServletContextEvent event) { closeWebApplicationContext(event.getServletContext()); ContextCleanupListener.cleanupAttributes(event.getServletContext()); }}可以看出其实现了ServletContextListener接口中的contextInitialized和contextDestroyed两个方法。ServletContextListener 是 ServletContext 的监听者,如果 ServletContext 发生变化,如服务器启动时 ServletContext 会被创建,服务器关闭时 ServletContext 将要被销毁。而整个加载过程由ContextLoader来完成,spring中的bean也由其创建。
0 0
- 【随笔】Spring中的监听器ContextLoaderListener
- spring项目中,web.xml中的 ContextLoaderListener监听器的原理
- Spring :监听器ContextLoaderListener的作用
- Spring监听器ContextLoaderListener的作用
- spring监听器ContextLoaderListener的疑问
- Spring监听器ContextLoaderListener的作用
- Spring监听器ContextLoaderListener的作用
- Spring :监听器ContextLoaderListener的作用
- spring项目中监听器作用-ContextLoaderListener
- spring项目中监听器作用-ContextLoaderListener
- Spring——监听器ContextLoaderListener作用
- Spring中的ContextLoaderListener
- Spring中的ContextLoaderListener作用
- Spring中的ContextLoaderListener作用
- Spring中的ContextLoaderListener
- Spring中的ContextLoaderListener作用
- Spring中的ContextLoaderListener作用
- Spring中的ContextLoaderListener作用
- 前端招聘必看!总结的太好了
- http协议
- iGrimaceR8_在线源安装
- BZOJ 3476: [Usaco2014 Mar]The Lazy Cow
- Hdu5128 - The E-pang Palac
- 【随笔】Spring中的监听器ContextLoaderListener
- 第九周OJ总结<2>-ASCII码排序
- 稻草人 贪心
- 数据结构(一)顺序表1:顺序存储的基本操作
- windows ftp Linux
- 灵敏度的定义
- MyEclipse2014部署maven web项目失败
- 微服务架构(Microservice Architect Pattern)综述——什么是微服务架构(读书笔记)
- iOS 开发 xcode中的project.pbxproj--深入剖析