web容器中實例化spring相關配置的示例分析

這篇文章主要介紹web容器中實例化spring相關配置的示例分析,文中介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們一定要看完!

創(chuàng)新互聯(lián)主營懷來網(wǎng)站建設的網(wǎng)絡公司,主營網(wǎng)站建設方案,app軟件定制開發(fā),懷來h5重慶小程序開發(fā)搭建,懷來網(wǎng)站營銷推廣歡迎懷來等地區(qū)企業(yè)咨詢

web容器中實例化spring相關配置說明:

要想在web容器實例化時加載spring容器,web.xml文件中配置如下:

<context-param>
  <param-name>contextConfigLocation</param-name>
  <param-value>classpath:bean.xml</param-value>
</context-param>
<!-- 對Spring容器進行實例化的監(jiān)聽器s -->
<listener>
   <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

說明:

默認情況下spring實例化時加載的是/WEB-INF/下的applicationContext.xml

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

<param-value>classpath:bean.xml</param-value>指定了spring需要加載的文件(類路徑下的bean.xml文件)

如果配置文件有多個配置如下:

  <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>
      classpath*:conf/spring/applicationContext_core*.xml,
      classpath*:conf/spring/applicationContext_dict*.xml,
      classpath*:conf/spring/applicationContext_hibernate.xml,
      classpath*:conf/spring/applicationContext_staff*.xml,
      classpath*:conf/spring/applicationContext_security.xml
      classpath*:conf/spring/applicationContext_modules*.xml
      classpath*:conf/spring/applicationContext_cti*.xml
      classpath*:conf/spring/applicationContext_apm*.xml
    </param-value>
  </context-param>

或者(使用空格隔開,如下配置:)

 <CONTEXT-PARAM>
     <PARAM-NAME>contextConfigLocation</PARAM-NAME>
     <PARAM-VALUE>
        applicationContext-database.xml applicationContext.xml
     </PARAM-VALUE> 
   </CONTEXT-PARAM>

以上是“web容器中實例化spring相關配置的示例分析”這篇文章的所有內(nèi)容,感謝各位的閱讀!希望分享的內(nèi)容對大家有幫助,更多相關知識,歡迎關注創(chuàng)新互聯(lián)行業(yè)資訊頻道!

網(wǎng)頁題目:web容器中實例化spring相關配置的示例分析
本文來源:http://bm7419.com/article0/jdigoo.html

成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供定制網(wǎng)站、ChatGPT、關鍵詞優(yōu)化、電子商務、網(wǎng)站收錄、網(wǎng)站設計

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

網(wǎng)站托管運營