<servlet>
<servlet-name>spring</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/bean.xml, /WEB-INF/bean-service.xml,
/WEB-INF/bean-dao.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern>*.html</url-pattern>
</servlet-mapping>
Note that in above code snippet, we have passed an init-param to DispatcherServlet called contextConfigLocation. Using this parameter not only can we change the name of Spring’s web context file but also change its location.
This parameter will call setContextConfigLocation method on DispatcherServlet and overrides default context config file. Note that it is possible to add multiple locations separated by any number of commas and spaced.
http://viralpatel.net/blogs/change-spring-servlet-filename-configuration/
本文介绍如何通过init-param配置Spring的DispatcherServlet,实现更改Spring web应用上下文文件的名称及位置。利用contextConfigLocation参数可以指定多个配置文件的位置,从而灵活地调整Spring MVC应用的初始化配置。
4913

被折叠的 条评论
为什么被折叠?



