1. problem: the client sends an Ajax request, but the session times out.
2. solution:
Server: in the filter or interceptor, determine the Ajax request type and set a timeout flag.
Client: the Ajax request requires a global processing function to obtain the corresponding flag and process it accordingly.
- Add the following to the filter:
// If there is an Ajax Request Response Header, X-requested-with; If (req. getheader ("X-requested-")! = NULL & Req. getheader ("X-requested-with"). inclusignorecase ("XMLHttpRequest") {res. setstatus (911); // indicates Session Timeout return ;}
Foreground global processing Ajax:
$. Ajaxsetup ({Timeout: 4000, cache: false, complete: function (xhr, textstatus) {// Session Timeout if (xhr. status = 911) {window. location. href = ".. /login. JSP "// return to the application homepage return ;}}});
Ajax Session Timeout