首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

tomcat启动时Spring做了什么(1、创建ContextLoader)

2012-09-20 
tomcat启动时Spring做了什么(一、创建ContextLoader)在配置Spring 的时候,我们需要在web.xml文件中配置一个

tomcat启动时Spring做了什么(一、创建ContextLoader)
在配置Spring 的时候,我们需要在web.xml文件中配置一个listener如下:
<listener>
<listener-class>
    org.springframework.web.context.ContextLoaderListener
         </listener-class>
</listener>
当server启动的时候,需要初始化WebApplicationContext,那么就会调用ContextLoaderListener的contextInitialized方法,该方法如下:


事实上,此段静态代码是为了获取WebApplicationContext的实现,WebApplicationContext的策略是定义在一个叫做ContextLoader.properties的文件中,Spring给了默认的定义,内容如下:
org.springframework.web.context.WebApplicationContext=org.springframework.web.context.support.XmlWebApplicationContext
一般来说,Spring团队建议不要去修改它,直接使用即可。
获取ContextLoader.properties的classPath后,将它用Properties包装。
接下来就是初始化WebApplicationContext了。
(待续)

热点排行