码迷,mamicode.com
首页 > Web开发 > 详细

maven工程web层的web.xml配置文档内容

时间:2017-06-27 01:01:18      阅读:176      评论:0      收藏:0      [点我收藏+]

标签:out   utf-8   div   权限   mybatis   javaee   maven工程   version   bat   

下面是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配置文档内容

标签:out   utf-8   div   权限   mybatis   javaee   maven工程   version   bat   

原文地址:http://www.cnblogs.com/suiyisuixing/p/7082942.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!