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过期跳转。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值