java web怎么把shiro拦截器关掉
1个回答
展开全部
publicvoiddoFilter(ServletRequestrequest,ServletResponseresponse,FilterChainchain)throwsIOException,ServletException{HttpServletRequestreq=(HttpServletRequest)request;if(req.getSession().getAttribute("user")==null){req.setAttribute("error","请你先登录");//非法请求才会进到这里面,在这里保存请求的url地址,在成功登录后再进行跳转req.getSession().setAttribute("goUrl",req.getRequestURL()+"?"+req.getQueryString());request.getRequestDispatcher("/ulogin.jsp").forward(request,response);}else{chain.doFilter(request,response);}}上面的代码是过滤器中的代码下面的是servlet中的代码if(request.getSession().getAttribute("goUrl")!=null){Stringurl=(String)request.getSession().getAttribute("goUrl");response.sendRedirect(url);}else{response.sendRedirect("/webshopping/index.jsp");}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询