<?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" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0"> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> <!-- 一、上下文加载需要的配置文件 --> <context-param> <param-name>contextConfigLocation</param-name> <param-value> classpath:spring/spring-dao.xml, classpath:spring/spring-service.xml </param-value> </context-param> <!-- 二、字符过滤器 --> <filter> <filter-name>encodingFilter</filter-name> <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class> <async-supported>true</async-supported> <init-param> <param-name>encoding</param-name> <param-value>UTF-8</param-value> </init-param> </filter> <filter-mapping> <filter-name>encodingFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <!-- 三、spring的监听器 --> <!-- 3.1、内存泄漏处理监听器 此监听器必须放在Spring相关监听器中的第一个位置 专门用来处理Introspector内存泄漏问题的辅助类, spring不会出现这种内存泄漏问题,但Quartz,Struts可能会出现 <listener> <listener-class>org.springframework.web.util.IntrospectorCleanupListener</listener-class> </listener> --> <!-- 3.2、web容器启动触发的监听器 在web容器启动时,加载一些context-param标签指定的配置文件 --> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <!-- 3.3、HTTP请求的监听器 如果需要配置request、session、global-session作用域的bean,则需要配置以下监听器 <listener> <listener-class> org.springframework.web.context.request.RequestContextListener </listener-class> </listener> --> <!-- 四、spring-mvc的DispatcherServlet --> <servlet> <servlet-name>dispatcherServlet</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:spring/spring-mvc.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> <!-- 是否使用异步处理(servlet3.0新特新),可以提高并发能力 --> <async-supported>true</async-supported> </servlet> <!-- 五、对静态资源的访问交给DefaultServlet处理 放在DispatcherServlet的mapping之前可以 不经过spring的DispatcherServlet 可提升性能 <servlet-mapping> <servlet-name>default</servlet-name> <url-pattern>*.css</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>default</servlet-name> <url-pattern>*.js</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>default</servlet-name> <url-pattern>*.jpg</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>default</servlet-name> <url-pattern>*.JPG</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>default</servlet-name> <url-pattern>*.jpeg</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>default</servlet-name> <url-pattern>*.JPEG</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>default</servlet-name> <url-pattern>*.png</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>default</servlet-name> <url-pattern>*.PNG</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>default</servlet-name> <url-pattern>*.gif</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>default</servlet-name> <url-pattern>*.GIF</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>default</servlet-name> <url-pattern>*.ico</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>default</servlet-name> <url-pattern>*.swf</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>default</servlet-name> <url-pattern>*.html</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>default</servlet-name> <url-pattern>*.zip</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>default</servlet-name> <url-pattern>*.ttf</url-pattern> </servlet-mapping> --> <servlet-mapping> <servlet-name>dispatcherServlet</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> <!-- 六、druid数据源监控servlet 访问ip:port/项目名/druid可以访问到druid数据源的监控页面 <servlet> <servlet-name>DruidStatView</servlet-name> <servlet-class>com.alibaba.druid.support.http.StatViewServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>DruidStatView</servlet-name> <url-pattern>/druid/*</url-pattern> </servlet-mapping> --> <!-- 七、session失效时间配置 --> <session-config> <session-timeout>15</session-timeout> </session-config> </web-app>
原文地址:https://www.cnblogs.com/javafucker/p/8647431.html
时间: 2024-10-14 19:17:17