Spring-學習筆記(ContextLoaderListener)

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

 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章