[Spring]web.xml中配置ContextLoaderListener监听器的作用
来源:互联网 发布:农村金融发展数据分析 编辑:程序博客网 时间:2024/06/02 19:58
在spring的核心配置文件中,为什么配置ContextLoaderListener监听器
- 1
- 2
- 3
- 1
- 2
- 3
打开ContextLoaderListener的源码,发现ContextLoaderListener实现了ServletContextListener接口
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
实现了ServletContextListener接口的作用就是当项目一经启动,就会激活实现了此接口的类方法,可以进行相关的初始化操作。
ServletContextListener接口实现了
public void contextInitialized(ServletContextEvent event)与
public void contextDestroyed(ServletContextEvent event)
两个方法,
意味着项目一经启动,会进入contextInitialized方法中,进行Spring的相关配置。并且contextInitialized方法有ServletContext参数,可以在web.xml中配置参数,用来ServletContext读取相关Spring配置文件, 一般 Dao, Service 的 Spring 配置都会在 listener 里加载。
项目退出时激活contextDestroyed方法。
结尾:
阅读全文
1 0
- [Spring]web.xml中配置ContextLoaderListener监听器的作用
- [Spring]web.xml中配置ContextLoaderListener监听器的作用
- spring项目中,web.xml中的 ContextLoaderListener监听器的原理
- Spring :监听器ContextLoaderListener的作用
- Spring监听器ContextLoaderListener的作用
- Spring监听器ContextLoaderListener的作用
- Spring监听器ContextLoaderListener的作用
- Spring :监听器ContextLoaderListener的作用
- JavaEE 下面使用Spring 时 web.xml 中ContextLoaderListener的作用及配置,多个配置文件时contextConfigLocation的作用
- web.xml文件中配置spring的ContextLoaderListener后报错
- web.xml配置文件中ContextLoaderListener的作用
- spring项目中监听器作用-ContextLoaderListener
- spring项目中监听器作用-ContextLoaderListener
- 监听器ContextLoaderListener的作用
- 监听器的作用-ContextLoaderListener
- spring中ContextLoaderListener的作用
- web.xml配置spring监听器
- web.xml中spring如何通过ContextLoaderListener初始化的
- CMarkUp使用简介,XML读取
- 笔记
- 转 SpringMVC与iReport(JasperReports) 5.6整合开发实例
- javaweb基础-servlet
- 利用redis + lua解决抢红包高并发的问题
- [Spring]web.xml中配置ContextLoaderListener监听器的作用
- Android 自定义模拟时钟控件
- win7安装plsql
- [Unity&]缺少引用空间Utility的解决办法
- IHookHelper
- Angular初探
- js中文转换为urlcode
- Java中静态代码块,普通代码块,构造函数详解
- xp 系统安装 Microsoft .NET Framework v4.0 问题