In the login filter. Request to infer whether the request is an AJAX request or a hyperlink or a change in the address bar
if (Httpservletreq.getheader ("X-requested-with")! = NULL
&& Httpservletreq.getheader ("X-requested-with"). Equalsignorecase ("XMLHttpRequest"))
{
Jsonobject jsessiontimeout = new Jsonobject ();
Jsessiontimeout.put ("Sessiontimeout", true);
Response.getwriter (). Print (jsessiontimeout.tostring ());
Response.getwriter (). Flush ();
Response.getwriter (). Close ();
}
else {
Gologin (Httpservletreq, httpservletres);
}
Js
/*******************************************************************************
* Infer if the session timed out. All dynamic requests need to be inferred
******************************************************************************/
function Cheacksessiontimeout (data) {
if (Isjson (data))
{
if (data.sessiontimeout==true) {
Reload the address of the browser address bar and jump to the landing page
Window.location.reload ();
}
}
};
Cheacksessiontimeout (data) is called after all AJAX request data is successful;
$.post (
Url
{},
function (data)
{
Cheacksessiontimeout (data);
}
);
Session invalidation, using AJAX request data interception, the normal processing logic is to jump to the login interface, not the interface does not change (Java inference is Ajax request)