1. 程式人生 > 其它 >ssm框架中如何整合多個spring的配置檔案?

ssm框架中如何整合多個spring的配置檔案?

技術標籤:javaspring

在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作為配置檔案