spring项目中监听器作用
18页1、spring项目中监听器作用 1 spring框架的启动入口 ContextLoaderListener2作用:在启动Web容器时,自动装配SpringapplicationContext.xml的配置信息。因为它实现了ServletContextListener这个接口,在web.xml配置这个监听器,启动容器时,就会默认执行它实现的方法。在ContextLoaderListener中关联了ContextLoader这个类,所以整个加载配置过程由ContextLoader来完成 pring在web下的入口在配置文件web.xml的监听器中<listener> <listener-class> org.springframework.web.context.ContextLoaderListener </listener-class></listener><context-param> <param-name>contextConfigLocation</param-name> <param-va
2、lue>classpath:conf/spring/applicationContext.xml</param-value></context-param>上述是在web.xml中的配置信息。 /实现了接口ServletContextListener,也就是说他必须实现contextDestroyed, contextInitialized这两个方法publicclass ContextLoaderListener implements ServletContextListener privateContextLoader contextLoader; /* *Initialize the root web application context. */Spring框架由此启动, contextInitialized也就是监听器类的main入口函数 publicvoid contextInitialized(ServletContextEvent event) this.contextLoader = createContextLoader(); this
3、.contextLoader.initWebApplicationContext(event.getServletContext(); /* * Createthe ContextLoader to use. Can be overridden in subclasses. * returnthe new ContextLoader */ protectedContextLoader createContextLoader() return new ContextLoader(); /* * Returnthe ContextLoader used by this listener. * returnthe current ContextLoader */ publicContextLoader getContextLoader() return this.contextLoader; /* * Closethe root web application context. */ publicvoid contextDestroyed(ServletContextEvent event)
《spring项目中监听器作用》由会员206****923分享,可在线阅读,更多相关《spring项目中监听器作用》请在金锄头文库上搜索。
人教版小学英语单词分类记忆汇总表excel版
人教版九年级全一册英语词汇
2019年开展垃圾分类的工作总结报告【五篇】
六年级英语绘本教案
外研版小学英语单词表全带音标(一年级起点1-12册)
最新国家开放大学电大投资学网络核心课形考网考作业及答案
初中人教版七年级下册生物复习提纲
高中英语语法大全高中英语语法系统全解word版
☆初中英语语法专项练习习题以及答案
初中英语常考近义词同义词辨析
高中物理选修3-5全套教案(人教版) (1)
英语绘本《WeatherReport》教学设计
防护功能平战转换设计专篇各专业
初中人教版七年级上册下册全册生物复习提纲21页 (1)
商务星球版七年级上册地理知识点归纳总结
初中人教版七年级上册下册全册生物复习提纲21页 (2)
高中高考语文作文词汇句型优美句子万能语句大全
中考地理选择题专项复习550题含答案
北师大版七年级数学上册第四章基本平面图形单元测试题含解析
人教版七年级数学上册第一章有理数单元检测题解析版
2024-04-24 10页
2024-04-24 10页
2024-04-24 25页
2024-04-24 10页
2024-04-23 4页
2024-04-23 10页
2024-04-23 19页
2024-04-23 10页
2024-04-23 16页
2024-04-23 5页