<!--start the Spring MVC Annotation feature, complete the mapping of request and annotation pojo, add interceptors, class-level processor mappings--
Interceptor Configuration
public class HandlerInterceptor1 extends Handlerinterceptoradapter {///The Handlerinterceptoradapter adapter is generally inherited here @Override public boolean prehandle (HttpServletRequest request, httpservletresponse response, Object handler) throws Exception {if (Request.getheader ("X-requested-with")! = null&& Request.getheader ("X-requested-with"). EqualsIgnoreC ASE ("XMLHttpRequest")//If the AJAX request response header will have, X-requested-with; </span><div style= "Color:rgb (153, 51, 102) ;" ><span style= "FONT-SIZE:12PX;" > { </span></div><div style= "Color:rgb (153, 51, 102);" ><span style= "FONT-SIZE:12PX;" > response.setheader ("Sessionstatus", "timeout"),//In the response header set session state & nbsp Response.getwriter (). Print ("timeout"); Print a return value, without this line, cannot jump out of the tabs page (<span style= "FONT-SIZE:12PX;" > Navigation bar can jump out </span>) return true; } @Override public void Posthandle (HttpservleTrequest request, HttpServletResponse response, Object handler, Modelandview Modelandview) throws Exception {Sys Tem.out.println ("===========handlerinterceptor1 posthandle"); } @Override public void aftercompletion (HttpServletRequest request, httpservletresponse response, Object handler , Exception ex) throws Exception {System.out.println ("===========handlerinterceptor1 aftercompletion"); } }
A global JS is required
$.ajaxsetup ({error:function (XMLHttpRequest, Textstatus, Errorthrown) {if (xmlhttprequest.status==403) {alert (' You do not have access to this resource or do this); return false;}, complete:function (xmlhttprequest,textstatus) { var sessionstatus= Xmlhttprequest.getresponseheader ("Sessionstatus"); Get the response header via XMLHttpRequest, Sessionstatus, if (sessionstatus== ' timeout ') { //If the timeout is processed, specify the page to jump var top = Gettopwinow (); Gets the top-level window object of the current page alert (' Login timeout, please log in again. '); top.location.href=path+ "/login.jsp"; Jump to landing page } } ); /** * Gets the top-level window in any nested hierarchy window in the page * @return The top-level window object of the current page */function Gettopwinow () { var p = window; while (P! = p.parent) { p = p.parent; } return p; }
Spring MVC Session Timeout Easyui tab page Ajax request out of question