web.xml常用配置

0

<?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:jsp="http://java.sun.com/xml/ns/javaee/jsp" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
	
	<display-name>www.acgist.com</display-name>
	
	<welcome-file-list>
		<welcome-file>index.jsp</welcome-file>
		<welcome-file>index.html</welcome-file>
	</welcome-file-list>
	
	<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>
	</filter>
	<filter-mapping>
		<filter-name>encodingFilter</filter-name>
		<url-pattern>/*</url-pattern>
	</filter-mapping>
	
	<filter>
		<filter-name>adminFilter</filter-name>
		<filter-class>com.acgist.web.filter.AdminFilter</filter-class>
	</filter>
	<filter-mapping>
		<filter-name>adminFilter</filter-name>
		<url-pattern>/admin/*</url-pattern>
	</filter-mapping>
	
	<filter>
		<filter-name>pageCachingFilter</filter-name>
		<filter-class>net.sf.ehcache.constructs.web.filter.SimplePageCachingFilter</filter-class>
		<init-param>
			<param-name>suppressStackTraces</param-name>
			<param-value>false</param-value>
		</init-param>
		<init-param>
			<param-name>cacheName</param-name>
			<param-value>pageCache</param-value>
		</init-param>
	</filter>
	<filter-mapping>
		<filter-name>pageCachingFilter</filter-name>
		<url-pattern>/image</url-pattern>
	</filter-mapping>
	<filter-mapping>
		<filter-name>pageCachingFilter</filter-name>
		<url-pattern>/article</url-pattern>
	</filter-mapping>
	<filter-mapping>
		<filter-name>pageCachingFilter</filter-name>
		<url-pattern>/common/*</url-pattern>
	</filter-mapping>
	<filter-mapping>
		<filter-name>pageCachingFilter</filter-name>
		<url-pattern>/index.jsp</url-pattern>
	</filter-mapping>
	
	<context-param>
		<param-name>contextConfigLocation</param-name>
		<param-value>classpath*:/applicationContext.xml</param-value>
	</context-param>
	
	<servlet>
		<servlet-name>mvc</servlet-name>
		<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
		<init-param>
			<param-name>contextConfigLocation</param-name>
			<param-value>classpath*:/applicationContext-mvc.xml</param-value>
		</init-param>
		<load-on-startup>1</load-on-startup>
	</servlet>
	<servlet-mapping>
		<servlet-name>mvc</servlet-name>
		<url-pattern>/</url-pattern>
	</servlet-mapping>
	
	<listener>
		<listener-class>com.acgist.web.listener.BeforeSpringInitListener</listener-class>
	</listener>
	<listener>
		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
	</listener>
	<listener>
		<listener-class>com.acgist.web.listener.AfterSpringInitListener</listener-class>
	</listener>
	
	<jsp-config>
		<taglib>
			<taglib-uri>http://com.acgist.tags.acgist.tld</taglib-uri>
			<taglib-location>/WEB-INF/tags/acgist.tld</taglib-location>
		</taglib>
	</jsp-config>
	
	<error-page>
		<error-code>404</error-code>
		<location>/WEB-INF/template/common/404.jsp</location>
	</error-page>
	<error-page>
		<error-code>405</error-code>
		<location>/WEB-INF/template/common/404.jsp</location>
	</error-page>
	<error-page>
		<exception-type>java.lang.Exception</exception-type>
		<location>/WEB-INF/template/common/exception.jsp</location>
	</error-page>
	
</web-app>