spring mvc 怎么指定spring.xml的配置文件,在web.xml中指定

时间:2021-01-13 20:31:35

web.xml文件配置

<?xml version="1.0" encoding="UTF-8"?>

<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns="http://java.sun.com/xml/ns/j2ee" 
xmlns:javaee="http://java.sun.com/xml/ns/javaee" 
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4">
  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>
  <servlet>
  <servlet-name>Dispatcher</servlet-name>
  <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
  <init-param>

  <param-name>contextConfigLocation</param-name>

             <!--指定spring配置文件地址,如果不指定,就放在默认位置-->

  <param-value>classpath:applicationContext.xml</param-value>

  <!--还可以这么指定

        <param-value>classpath*:com/feizi/config/SpringMVC-servlet.xml</param-value>

-->

  </init-param>
  </servlet>
  <servlet-mapping>
  <servlet-name>Dispatcher</servlet-name>
  <url-pattern>*.do</url-pattern>
  </servlet-mapping>  

</web-app>