1. 程式人生 > >關於ContextLoaderListener的預設配置檔案位置

關於ContextLoaderListener的預設配置檔案位置

applicationContext.xml只能放在WEB-INF資料夾下。

導致這個問題的原因是:ContextLoaderListener預設去WEB-INF下載入applicationContext.xml配置。

可以根據以下配置來修改配置檔案位置:

<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- 修改配置檔案路徑 -->
<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath:spring/applicationContext.xml</param-value>
</context-param>