`
sd1992585
  • 浏览: 48763 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
文章分类
社区版块
存档分类
最新评论

extjs实现session过期跳转

阅读更多

extjs基于ajax实现,因为是异步请求,所以一般的jsp session过期跳转方式不可用,但是当它session过期时会手动去在页面头信息x-requested-with中插入XMLHttpRequest值,可以利用这

点去进行exjs的session过期处理。这里提供大家一个方法:

写一个Sessionfilter过滤器,检查是否session过期,过期时间通过web.xml配置(不明白具体步骤的上百度或者google详查),

String head = httpRequest.getHeader("x-requested-with");(获得extjs session过期值)
if (head != null && !(head.equalsIgnoreCase("XMLHttpRequest"))) { 
 if (sessionUser == null) { 
  httpResponse.sendError(999); //添加respone报错信息
  filter.doFilter(httpRequest, httpResponse); 
 }
 else{
  filter.doFilter(httpRequest, httpResponse); 
 }
}

 

js中需要用到extjs中一个事件:

 Ext.Ajax.on('requestexception',function(conn,response,options) {
     if(response.status=="999"){
         Ext.Msg.alert('提示', '会话超时,请重新登录!', function(){
          var url = document.getElementById("atsurlid").value;
             parent.location.href = url+'login.jsp';  
         });   
     }      
 });

 

然后可以实现session过期跳转。

3
2
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics