我想在我所有jsp页面的标题中应用一些代码,它会自动检测会话何时超时并重定向到登录页面。
有可能吗?
任何人都有一些想法请告诉我
答案 0 :(得分:1)
您可以使用JavaScript检查会话超时。请尝试以下方法:
var timeOut = 1000 * 60 * 30; // Default session time out 30 minutes in jsp
var now = new Date().getTime();
var check;
check= function(){
if(new Date().getTime() > now + timeOut){
window.location='login.jsp' // Which page you need
}else{
window.setTimeout(checkTimeOut, 1000); // Here we check once per second but you change how you wish
}
}
我希望这会对你有所帮助