设备资源管理系统-过滤器

设备资源管理系统-过滤器

  •   添加过滤器

  操作:

      1、创建一个类CheckLogonUserFilter,实现javax.servlet.Filter

      2、获得方法:

           public void init(FilterConfig arg0) throws ServletException {

             1)初始化不能被过滤的连接(存放到List对象中)

           }

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

             1)获取当前操作的所有连接,与初始化中的不能被过滤的连接进行对比,如果不包含不被过滤的连接,则不能放行,跳转到首页面

             2)从request中获取session,从session中再获取当前登录的用户信息,判断用户是否为空,如果为空,跳转到首页面

       }

       public void destroy() {

       }

在Web.xml中添加过滤器

原文地址:https://www.cnblogs.com/yangml/p/3819217.html