Sring 是通过listener来加载配置文件的.
<!-- 加载spring容器 -->
<context-param><param-name>contextConfigLocation</param-name>
<param-value>classpath:spring/applicationContext-*.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
SpringMvc加载方式--通过一个servlet来加载的.而且.配置文件的初始化方式,也是不一样的.
<!-- springmvc的前端控制器 -->
<servlet>
<servlet-name>taotao-search-web</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<!-- contextConfigLocation不是必须的, 如果不配置contextConfigLocation, springmvc的配置文件默认在:WEB-INF/servlet的name+"-servlet.xml" -->
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring/springmvc.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>taotao-search-web</servlet-name>
<url-pattern>*.html</url-pattern>
</servlet-mapping>