网上图书商城11--后台登录过滤器
程序员文章站
2022-03-21 14:14:03
...
1.web.xml
AdminLoginFilter cn.itcast.goods.admin.web.filter.AdminLoginFilter AdminLoginFilter /adminjsps/admin/* /admin/*
2.AdminLoginFilter
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { HttpServletRequest req = (HttpServletRequest) request; Object admin = req.getSession().getAttribute("admin"); if(admin == null) { request.setAttribute("msg", "您还没有登录,不要瞎遛达!"); request.getRequestDispatcher("/adminjsps/login.jsp").forward(request, response); } else { chain.doFilter(request, response); } }
上一篇: 小米明年1月发布4800万像素摄像头手机