spring配置文件路径修改后web.xml配置
生活随笔
收集整理的這篇文章主要介紹了
spring配置文件路径修改后web.xml配置
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
在web.xml中加入
<listener> <listener-class> org.springframework.web.context.ContextLoaderListener </listener-class> </listener>
這樣系統(tǒng)會(huì)自動(dòng)讀取/WEB-INF/applicationContext.xml
如果自己定義文件名,還需要增加
<context-param> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:applicationContext.xml</param-value> </context-param> </context-param>
此時(shí)的applicationContext.xml在src目錄下
<listener> <listener-class> org.springframework.web.context.ContextLoaderListener </listener-class> </listener>
這樣系統(tǒng)會(huì)自動(dòng)讀取/WEB-INF/applicationContext.xml
如果自己定義文件名,還需要增加
<context-param> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:applicationContext.xml</param-value> </context-param> </context-param>
此時(shí)的applicationContext.xml在src目錄下
轉(zhuǎn)載于:https://blog.51cto.com/3001448/1205804
總結(jié)
以上是生活随笔為你收集整理的spring配置文件路径修改后web.xml配置的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: Linux命令之whereis
- 下一篇: GC 垃圾回收