判断没登录就跳转php,js判断用户是否登录没有登录的话跳转到登录页面登录

公共无效的doFilter(ServletRequest的要求,ServletResponse的响应,FilterChain的链)抛出IOException,ServletException异常{

HttpServletRequest的REQ =(HttpServletRequest的)要求;

(req.getSession()。的getAttribute(“用户”)== NULL){

req.setAttribute(“错误”,“请记录);

/ /非法的请求后,它一直在那里保存的URL地址的请求,在成功登录后跳 req.getSession()的setAttribute(“:goUrl req.getRequestURL()+”“+ req.getQueryString());要求

。 getRequestDispatcher(/ ulogin.jsp“)。向前(请求,响应);

}

其他{

chain.doFilter(请求,响应);

}

}

代码上述过滤器的代码

以下是servlet代码

(request.getSession()。的getAttribute(“goUrl)!= NULL){

字符串URL =(字符串)request.getSession() 。的getAttribute(“goUrl”);

response.sendRedirect是(URL);

}

其他{

response.sendRedirect是(“/ webshopping / index.jsp的”); />}

取消

评论