web.xml配置
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd" version="4.0"> <!-- 配置SpringMVC的前端控制器DispatcherServlet url-pattern中/和/*的区别: / 匹配浏览器向服务器发送的所有请求(不包括.jsp路径的请求,DispatcherServlet不能处理jsp) /* 匹配浏览器向服务器发送的所有请求(包括.jsp路径的请求) SpringMVC配置文件的默认位置和名称:WEB-INF下<servlet-name>-servlet.xml,如:SpringMVC-servlet.xml --> <servlet> <servlet-name>SpringMVC</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <!--设置SpringMVC配置文件的位置和名称--> <init-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:springmvc.xml</param-value> </init-param> <!--将DispatcherServlet的初始化时间提前到服务器启动时--> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>SpringMVC</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> </web-app>
标签:xml,web,springmvc,SpringMVC,servlet,resources From: https://www.cnblogs.com/ixtao/p/17185800.html