• 过滤器


    public void doFilter(ServletRequest arg0, ServletResponse arg1,
    FilterChain arg2) throws IOException, ServletException {

    //进入服务器之前
    System.out.println("进入服务器之前>>>>");

    HttpServletRequest req=(HttpServletRequest) arg0;
    req.setCharacterEncoding(encoding);
    if(req.getSession().getAttribute("user")==null){
    HttpServletResponse res=(HttpServletResponse) arg1;

    res.sendRedirect("login.jsp");
    }else{
    arg2.doFilter(arg0, arg1);
    String path=req.getRequestURI();
    System.out.println("你请求的路径是:"+path);
    System.out.println("<<<<<进入服务器之后");
    }
    //进入服务器之后
    }


    public class MyFilter implements Filter {

    public void destroy() {
    // TODO Auto-generated method stub

    }

    public void doFilter(ServletRequest arg0, ServletResponse arg1,
    FilterChain arg2) throws IOException, ServletException {
    System.out.println("进入Filter");
    arg2.doFilter(arg0, arg1);//----->
    System.out.println("离开Filter");
    }

    public void init(FilterConfig arg0) throws ServletException {
    System.out.println("初始化");
    }

    }

  • 相关阅读:
    iOS开发UI篇—xib的简单使用
    iOS开发UI篇—字典转模型
    iOS开发UI篇—九宫格坐标计算
    iOS开发UI篇—懒加载
    2020121301-01
    2020120501-01
    2020113001-梦断代码-3
    2020112801-01
    2020112401
    2020112201-1
  • 原文地址:https://www.cnblogs.com/tian114527375/p/4937639.html
Copyright © 2020-2023  润新知