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