web.xml中的contextConfigLocation的作用

在web.xml中通過contextConfigLocation配置spring,contextConfigLocation
 參數定義了要裝入的 Spring 配置文件。
如果想裝入多個配置文件,可以在 <param-value> 標記中用逗號作分隔符。

在web.xml裏配置Listener

xml 代碼如下: 
  < listener >  
       <    listener-class > org.springframework.web.context.ContextLoaderListener listener-class >  
  <   /  listener >   

如果在web.xml裏給該Listener指定要加載的xml,如:

xml代碼如下:

<!-- spring config -->

      <context-param>

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

           <param-value>classpath:applicationContext.xml</param-value>

      </context-param>

則會去加載相應的xml,而不會去加載/WEB-INF/下的applicationContext.xml。

但是,如果沒有指定的話,默認會去/WEB-INF/下加載applicationContext.xml。

發佈了29 篇原創文章 · 獲贊 33 · 訪問量 36萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章