ssm框架中如何整合多個spring的配置檔案?
阿新 • • 發佈:2021-01-22
在web.xml中配置轉換器(DispatcherServlet)時,使用contextConfigLocation引數進行配置,如下:
<servlet>
<servlet-name>spring-dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name >contextConfigLocation</param-name>
<param-value>classpath:spring/spring-*.xml</param-value>
</init-param>
</servlet>
classpath:spring/spring-*.xml:
對應筆者的目錄結構:
*
如果不配置contextConfigLocation,預設的是查詢/WEB-INF/applicationContext.xml作為配置檔案