Spring Mvc Session超时easyui tab页中ajax请求跳出问题
来源:互联网 发布:超级英雄淘宝购买礼包 编辑:程序博客网 时间:2024/05/19 17:10
<!-- 启动Spring MVC的注解功能,完成请求和注解POJO的映射,添加拦截器,类级别的处理器映射 -->
拦截器配置
public class HandlerInterceptor1 extends HandlerInterceptorAdapter {//此处一般继承HandlerInterceptorAdapter适配器即可 @Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { if (request.getHeader("x-requested-with") != null&& request.getHeader("x-requested-with").equalsIgnoreCase("XMLHttpRequest"))//如果是ajax请求响应头会有,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");//在响应头设置session状态 response.getWriter().print("timeout"); //打印一个返回值,没这一行,在tabs页中无法跳出(<span style="font-size:12px;">导航栏能跳出</span>) return true; } @Override public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception { System.out.println("===========HandlerInterceptor1 postHandle"); } @Override public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception { System.out.println("===========HandlerInterceptor1 afterCompletion"); } }需要一个全局的js
$.ajaxSetup({ error: function (XMLHttpRequest, textStatus, errorThrown){if(XMLHttpRequest.status==403){alert('您没有权限访问此资源或进行此操作');return false;}}, complete:function(XMLHttpRequest,textStatus){ var sessionstatus=XMLHttpRequest.getResponseHeader("sessionstatus"); //通过XMLHttpRequest取得响应头,sessionstatus, if(sessionstatus=='timeout'){ //如果超时就处理 ,指定要跳转的页面 var top = getTopWinow(); //获取当前页面的顶层窗口对象 alert('登录超时, 请重新登录.'); top.location.href=path+"/login.jsp"; //跳转到登陆页面 } } }); /** * 在页面中任何嵌套层次的窗口中获取顶层窗口 * @return 当前页面的顶层窗口对象 */function getTopWinow(){ var p = window; while(p != p.parent){ p = p.parent; } return p; }
0 0
- Spring Mvc Session超时easyui tab页中ajax请求跳出问题
- EASYUI 中session 超时跳出Tabs
- Ajax请求Session超时问题
- Ajax请求Session超时问题
- mvc下ajax请求遇到session超时简单处理方式
- spring security:ajax请求的session超时处理
- AngularJS Ajax请求与Spring MVC登录超时解决方案
- session超时,处理ajax请求
- session超时,处理ajax请求
- session 超时,处理ajax请求
- ajax请求session 超时处理
- Ajax请求处理Session超时
- session超时,处理ajax请求
- Ajax请求session超时解决办法
- Ajax请求超时问题
- 在Ajax请求中处理登录session超时的方法
- spring MVC中ajax请求路径
- asp.net mvc session锁问题 Ajax请求慢问题
- POJ 1659 Frogs' Neighborhood 可图性判断-Havel定理
- 函数定义与使用
- 位运算符C语言
- 使用Vitamio打造自己的Android万能播放器(2)—— 手势控制亮度、音量、缩放
- 成人の日に考える―答え合わせと黒のスーツ
- Spring Mvc Session超时easyui tab页中ajax请求跳出问题
- rhel7.0安装图形桌面
- 浏览器兼容性改革
- 转MSDN里的CWnd::OnHScroll
- android -- 模块 android手机旋转屏幕时让GridView的列数与列宽度自适应
- Mac命令大全
- 71MainActivity中连接的监听
- VB自定义函数加 ""和 "";
- 两款齐发 魅蓝Note月底发电信版