改变spring-servlet.xml名字和默认位置

如何我们在web.xml定义:

改变spring-servlet.xml名字和默认位置
<servlet>
    <servlet-name>spring</servlet-name>
    <servlet-class>
        org.springframework.web.servlet.DispatcherServlet
    </servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>spring</servlet-name>
    <url-pattern>*.html</url-pattern>
</servlet-mapping>
改变spring-servlet.xml名字和默认位置

那么默认加载文件名字spring-servlet.xml 从webapps WEB-INF文件夹下。

如果我们想要自己定义名字和位置:

改变spring-servlet.xml名字和默认位置
<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</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>
改变spring-servlet.xml名字和默认位置

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.

改变spring-servlet.xml名字和默认位置
<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>
改变spring-servlet.xml名字和默认位置

改变spring-servlet.xml名字和默认位置

上一篇:虚拟地址空间


下一篇:[教程心得] Flash AIR 调用exe/bat且可以传参