From: http://www.jb51.net/article/43770.htm
If it is an Ajax commit, the jump command from the server will not work, so if it is a session timeout, and is in the AJAX request, in the response header, and then a global method to handle the session timeout to jump page.
Write the following method in the filter: (not tested)
Publicvoid DoFilter (ServletRequest request, servletresponse response,Filterchain chain) throws IOException,servletexception {httpservletrequest HttpRequest=(httpservletrequest) request; HttpServletResponse HttpResponse=(httpservletresponse) response;Stringurl = Httprequest.getrequesturl ().toString ();if(httprequest.getsession () = =NULL) { if(Httprequest.getheader ("X-requested-with")! =NULL&& Httprequest.getheader ("X-requested-with").Equals ("XMLHttpRequest")) {//Ajax RequestsHttpresponse.setheader ("Sessionstatus", "timeout"); } Else{HttpResponse. Sendredirect ("/test/index.jsp"); return; } } Else{chain. DoFilter (Request,response); } }
Thus, if the session times out and is an AJAX request, it will be in the response header, Sessionstatus has a timeout, and a global method to process the session timeout to jump to the page
jquery can be used $.ajaxsetup method, ext also has a similar method: (Test effective)
"Application/x-www-form-urlencoded;charset=utf-8 " function var // If (sessionstatus = = "Timeout"//window.location.replace ("/test /index.jsp "
The Ajax commit session Timeout jump page uses a global method to process