Spring MVC Session Timeout Easyui tab page Ajax request out of question

Source: Internet
Author: User

<!--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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.