public void invalidate()Invalidates this session then unbinds any objects bound to it. Throws: IllegalStateException - if this method is called on an already invalidated session//利用这个试试,就是有点浪费资源try { session.invalidate(); } catch(IllegalStateException e) { response.sendRedirect("/jsp/error.jsp?errorId=1"); }
if (session.isNew()){
以前的session失效
}
if (session.getAttribute("userName") == null) {
response.sendRedirect("/jsp/error.jsp?errorId=1");
}
为了使这个文件能用于任何系统里,就不能对session.getAttribute("userName")进行判断,因为不同的系统中用户登陆时设置的session中的参数不同
if (session.getAttribute("userName") == null) {
response.sendRedirect("/jsp/error.jsp?errorId=1");
}
为了使这个文件能用于任何系统里,就不能对session.getAttribute("userName")进行判断,因为不同的系统中用户登陆时设置的session中的参数不同
"为了使这个文件能用于任何系统里",这句话,不明白什么意思?什么叫任何系统?是指操作系统?为什么不同的系统中用户登陆时设置的session中的参数不同,能解释一下吗?
Throws:
IllegalStateException - if this method is called on an already invalidated session//利用这个试试,就是有点浪费资源try
{
session.invalidate();
}
catch(IllegalStateException e)
{
response.sendRedirect("/jsp/error.jsp?errorId=1");
}