1. 程式人生 > >maven工程web層的web.xml配置文檔內容

maven工程web層的web.xml配置文檔內容

ati exp expose param 過期 for work utf-8 xmlns

下面是web層,web.xml配置文檔裏面需要配置的東西:

1、lo4j配置

2、讀取spring文件配置

3、設計路徑變量值

4、spring字符集過濾器

5、登陸過濾器

6、springMVC核心配置

7、session過期時間

8、錯誤頁面跳轉

以下是實例:

<?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_3_0.xsd" id="WebApp_ID" version="3.0"> <display-name>bridgechart-web</display-name> <!-- log4j 配置 --> <context-param> <param-name>log4jConfigLocation</param-name
> <param-value>classpath:properties/log4j.properties</param-value> </context-param> <!-- load log4j --> <listener> <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class> </listener> <!-- 讀取spring配置文件
--> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:xml/spring.xml; classpath:xml/spring-mybatis.xml <!-- ;classpath:xml/spring-job.xml --> </param-value> </context-param> <!-- 設計路徑變量值 --> <context-param> <param-name>webAppRootKey</param-name> <param-value>bridgechart-web.root</param-value> </context-param> <context-param> <param-name>log4jExposeWebAppRoot</param-name> <param-value>false</param-value> </context-param> <!-- Spring字符集過濾器 --> <filter> <filter-name>SpringEncodingFilter</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> <param-name>forceEncoding</param-name> <param-value>true</param-value> </init-param> </filter> <filter-mapping> <filter-name>SpringEncodingFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <!-- 登錄過濾器 --> <filter> <filter-name>PagesFilter</filter-name> <filter-class>com.mmc.d4alc.controller.PagesFilter</filter-class> </filter> <filter-mapping> <filter-name>PagesFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <!-- springMVC核心配置 --> <servlet> <servlet-name>spring</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:xml/spring-mvc.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>spring</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>default</servlet-name> <url-pattern>*.mp4</url-pattern> </servlet-mapping> <welcome-file-list> <welcome-file>login.jsp</welcome-file> </welcome-file-list> <!-- session過期時間--> <session-config> <session-timeout>10</session-timeout> </session-config> <!-- 錯誤跳轉頁面 --> <error-page> <!-- 路徑不正確 --> <error-code>404</error-code> <location>/view/common/404.jsp</location> </error-page> <error-page> <!-- 沒有訪問權限,訪問被禁止 --> <error-code>405</error-code> <location>/view/common/405.jsp</location> </error-page> <error-page> <!-- 內部錯誤 --> <error-code>500</error-code> <location>/view/common/500.jsp</location> </error-page> </web-app>

maven工程web層的web.xml配置文檔內容