zoukankan      html  css  js  c++  java
  • 原创:自定义过虑器及配置

    一:自定过滤器java书写

    二: web.xml配置

    一:自定过滤器java书写
    自定义过滤器,其实就是实现接口javax.servlet.Filter中的三个方法:init,doFilter,destroy

    package com.test;
    
    import javax.servlet.*;
    import java.io.IOException;
    
    public class FilterStudy implements Filter {
    
    
        @Override
        public void init(FilterConfig filterConfig) throws ServletException {
            System.out.println("asplover 自定义过虑器初始化");
        }
    
        @Override
        public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
            System.out.println("asplover 自定义过滤器要做的事情");
            System.out.println(servletRequest);
        }
    
        @Override
        public void destroy() {
            System.out.println("asplover 自定义过虑器销毁");
        }
    }

    二: web.xml配置

    <!--  过滤器配置标签有两个filter和filter-mapping-->
    <filter>
      <filter-name>filterStudy</filter-name>
      <filter-class>com.test.FilterStudy</filter-class>
      <init-param>
        <param-name>paraName2</param-name>
        <param-value>paraName2变量的值</param-value>
      </init-param>
    </filter>
      <filter-mapping>
        <filter-name>filterStudy</filter-name>
        <url-pattern>/*</url-pattern>
      </filter-mapping>
    做产品的程序,才是好的程序员!
  • 相关阅读:
    HorizontalScrollView水平滚动控件的使用
    ScrollView垂直滚动控件的使用
    RatingBar评分控件的使用
    ProgressBar进度条的使用
    AnalogClock和DigitalClock时间和日期控件
    DatePicker输入日期控件的使用
    ImageView从网络上获取图像
    CentOS 7.3 安装配置Samba服务器
    python元组内置函数
    Python元组
  • 原文地址:https://www.cnblogs.com/asplover/p/12887223.html
Copyright © 2011-2022 走看看