zoukankan      html  css  js  c++  java
  • 改变spring-servlet.xml名字和默认位置

    如何我们在web.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 从webapps WEB-INF文件夹下。

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

    <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>

    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.

    <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>
  • 相关阅读:
    linux系统telnet端口不通能收到SYN但不回SYN+ACK响应问题排查(转载)
    leveldb
    SSTable and Log Structured Storage: LevelDB
    fio terse输出详解
    bash的循环中无法保存变量
    怎样当好一个师长
    共享变量的并发读写
    Storage Systems topics and related papers
    Storage System and File System Courses
    调试std::string
  • 原文地址:https://www.cnblogs.com/king-sheng/p/3520990.html
Copyright © 2011-2022 走看看