<?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/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5"> <display-name>Archetype Created Web Application</display-name> <!--负责监听上下文spring-beans的加载--> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <!-- Spring beans 配置文件所在目录--> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:applicationContext.xml</param-value> </context-param> <!--路径问题: 不指定classpath:默认目录在WEB-INF下面 指定classpath:回到resources目录下面 --> <!-- spring mvc 配置--> <servlet> <servlet-name>spring</servlet-name> <!--请求分发 对应spring-servlet.xml配置文件,前缀spring和servlet一一对应的, 后缀-servlet是固定的,spring会自动读取按照这个格式定义的文件 --> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>spring</servlet-name> <url-pattern>/</url-pattern> <!--此处为什么使用 / 路径型匹配,而不使用 /* 后缀型匹配? 因为经过视图解析器,返回jsp视图时,不会经过该DispatcherServlet, jsp页面请求也不会命中该servlet,jsp容器内置的jsp servlet被调用 --> </servlet-mapping> <!-- 过滤器进行项目编码配置 --> <filter> <filter-name>encodingFilter</filter-name> <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class> <!--参数配置--> <init-param> <param-name>encoding</param-name> <param-value>UTF-8</param-value> </init-param> <init-param> <!--强制编码。强制使用utf-8编码--> <param-name>forceEncoding</param-name> <param-value>true</param-value> </init-param> </filter> <filter-mapping> <filter-name>encodingFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <!-- druid 配置 --> <servlet> <servlet-name>DruidStatServlet</servlet-name> <servlet-class>com.alibaba.druid.support.http.StatViewServlet</servlet-class> <!--登录验证配置--> <init-param> <param-name>loginUsername</param-name> <param-value>druid</param-value> </init-param> <init-param> <param-name>loginPasswoord</param-name> <param-value>druid</param-value> </init-param> </servlet> <servlet-mapping> <servlet-name>DruidStatServlet</servlet-name> <url-pattern>/sys/druid/*</url-pattern> </servlet-mapping> <filter> <filter-name>DruidStatFilter</filter-name> <filter-class>com.alibaba.druid.support.http.WebStatFilter</filter-class> <init-param> <param-name>exclusions</param-name> <param-value>*.js,*.css,*.jpg,*.png,*.ico,*.gif,/sys/druid/*</param-value> </init-param> </filter> <filter-mapping> <filter-name>DruidStatFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> </web-app>
原文地址:https://www.cnblogs.com/wangchengb/p/9011864.html
时间: 2024-10-04 06:18:37