SpringMvc + js + frame session User Logon timeout Solution

Source: Internet
Author: User

1. controller Control Layer Code :... @ SessionTimeOutAnnotation @ RequestMapping (value = "findSumRainList. hd ") @ ResponseBodypublic List findSumRainList (HttpServletRequest request, HttpServletResponse response ){....}...
2. Verify the core code of the session Timeout Section/*** system cut point class, and define the system level cut point **/@ Aspect @ Componentpublic class SessionTimeOutAspect {public SessionTimeOutAspect () {}@ Before (value = "@ annotation (org. wh. aspectj. annotation. sessionTimeOutAnnotation) ") public void sessionTimeOutExceptionAspect (JoinPoint jp) throws Exception {User user = null; for (Object param: jp. getArgs () {if (param instanceof HttpServletRequest) {user = (User) (H TtpServletRequest) param). getSession (). getAttribute (SystemConstants. SESSION_USER); break ;}} if (user = null) {throw new RuntimeException ("Operation timed out, please log on again! ");}}...} 3. js global function. The core capture Exception Code: function errAjaxEvent () {// use the normal page // $ ("body "). ajaxError (function (event, request, ajaxOptions, thrownError) {// use frame framework $ (parent. frames ["frame_main" example .doc ument ). ajaxError (function (event, request, ajaxOptions, thrownError) {try {if (request. responseText. indexOf ('Log On again ')> 0) {art. dialog ({title: 'hprompt ', content:' login timeout. Please log on again! ', Icon: 'warning', lock: true, OK: function () {window. parent. location. href = '.. /login. hd ';}}) ;}} catch (e) {}});} 4. web. xml...
         
  
   
30
      
     
         
  
   
Login. hd
      
 ...

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.