zoukankan      html  css  js  c++  java
  • web.xml和Filter的对应关系

    1.在SSM中的web.xml和Filter的对应关系

    package com.qingfeng.filter;
    
    public class UserFilter implements Filter {
        @Override
        public void init(FilterConfig filterConfig) throws ServletException {
        	System.out.println("进入了init方法。。。。。。" );
        }
        @Override
        public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
            System.out.println("进入了doFilter方法。。。。。。" );
        }
        @Override
        public void destroy() {
     System.out.println("进入了destroy方法。。。。。。" );
        }
    }
    

    2. 过滤器

    <!-- 配置过滤器 -->
    	<filter>
    		<filter-name>UserFilter</filter-name>
    		<filter-class>cn.tedu.store.filter. UserFilter </filter-class>
              <!--  给对象属性赋值-->
              <init-param>
    			<param-name>serverName1</param-name>
    			<param-value>http://localhost:8080</param-value>
    		</init-param>
    		<init-param>
    			<param-name>serverName2</param-name>
    			<param-value>http://localhost:8082</param-value>
    		</init-param>
    	</filter>
    	<filter-mapping>
    		<filter-name>UserFilter</filter-name>
              <!--这里使用*.do的请求才能filter过滤,允许访问,没有以.do结尾的都要被拦截,不被访问-->
    		<url-pattern>*.do</url-pattern>
    	</filter-mapping>
    

      

    3.web.xml和Filter的对应关系

  • 相关阅读:
    tp5.1 多级控制器
    JS中三个点(...)是什么鬼?
    vue reqwest与fetch的使用
    new Vue({ render: h => h(App), }).$mount('#app')到底什么意思
    ant design vue 表格和国际化的使用
    JAVA日报
    JAVA日报
    JAVA日报
    JAVA日报
    JAVA日报
  • 原文地址:https://www.cnblogs.com/Amywangqing/p/12896683.html
Copyright © 2011-2022 走看看