• Filter配置两种方式


    过滤器配置

    1. xml文件配置
    <filter>
            <filter-name>helloFilter</filter-name>
            <filter-class>com.hwua.filter.HelloFilter</filter-class>
        </filter>
    
        <filter-mapping>
            <filter-name>helloFilter</filter-name>
            <url-pattern>/alter.jsp</url-pattern>
            <!--过滤请求过来的页面-->
            <dispatcher>REQUEST</dispatcher>
            <!--过滤转发过来的页面-->
            <dispatcher>FORWARD</dispatcher>
            <!--过滤动态导入的页面-->
            <dispatcher>INCLUDE</dispatcher>
            <!--过滤因发生错误跳转过来的页面-->
            <dispatcher>ERROR</dispatcher>
        </filter-mapping>
    
        <error-page>
            <!--当应用中的某一个页面出现错误时,会直接跳转到index.jsp-->
            <exception-type>java.lang.ArithmeticException</exception-type>
            <location>/alter.jsp</location>
        </error-page>
    
    1. 注解配置
    /**
     *urlPatterns 要过滤的资源的名称
     *dispatcherTypes 要过滤的加载资源的方式 默认情况下请求request资源 才过滤 
     *      DispatcherType.ERROR    //错误页面跳转
     *      DispatcherType.FORWARD  //转发
     *      DispatcherType.INCLUDE  //动态加载页面
     *      DispatcherType.REQUEST  //请求
    @WebFilter(urlPatterns = "/*" ,dispatcherTypes = {DispatcherType.ERROR,DispatcherType.FORWARD,DispatcherType.INCLUDE,DispatcherType.REQUEST})
    
  • 相关阅读:
    python smtplib email
    python merry -- error handling in the real world
    python os.path
    python logging
    Python演讲笔记1
    python DBUtils.PooledDB 中 maxcached 和 maxconnections
    Effective Python2 读书笔记3
    Effective Python2 读书笔记2
    MVC验证session是否过期,在每个action执行之前验证
    int类型的正负数转换
  • 原文地址:https://www.cnblogs.com/yuing/p/8880679.html
Copyright © 2020-2023  润新知