Spring-学习笔记(ContextLoaderListener)

来源:互联网 发布:哥布林升级数据 编辑:程序博客网 时间:2024/06/13 14:17

1.范例

<context-param>

    <param-name>contextConfigLocation</param-name>

    <param-value>

        /WEB-INF/config/application-context.xml

       /WEB-INF/config/*-context.xml

    </param-value>

</context-param>

<listener>

    <listener-class>org.springframework.web.context.ContextLoader</listener-class>

</listener>

2.web.xml中配置<context-parm>的作用

2.1 启动一个web项目的时候,应用服务器(eg:tomcat)会去读取appplication的web.xml中

     1)<listener/>

     2)<context-param/>

2.2 listener会根据配置路径,去加载在文件中已经定义的BEAN,存放在ServletContext。在application scope中共享

      这个ServletContext.

3. org.springframework.web.context.ContextLoaderListener源码分析

3.1 class diagram

3.2 seqence diagram

 

 

 

0 0
原创粉丝点击