我的页面都是js写的 现在想如果session过期 就把页面转到登录页面, 但现在为什么不起作用啊?请各位指点一下啊:public class ControllerActionServlet extends ActionServlet {
protected void service(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
request.setCharacterEncoding("UTF-8");
String method = request.getParameter("action");
if(!"login".equals(method) ){
User user = (User) request.getSession().getAttribute("user");
//如果session中对象为空,则转到登陆页面
if(user==null){
request.getSession().getServletContext().getRequestDispatcher("/login.html").forward(request,response);
}
}
this.process(request, response);
}
}
protected void service(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
request.setCharacterEncoding("UTF-8");
String method = request.getParameter("action");
if(!"login".equals(method) ){
User user = (User) request.getSession().getAttribute("user");
//如果session中对象为空,则转到登陆页面
if(user==null){
request.getSession().getServletContext().getRequestDispatcher("/login.html").forward(request,response);
}
}
this.process(request, response);
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货