问题:项目配置了shiro,前端使用ajax请求,当session过期时,页面不跳转至登录页面,偶尔会跳转一下。通过debug模式中的network,发现前端的重定向地址已经是登录页面的地址。
![](https://img.haomeiwen.com/i13992909/229abe1d78553803.png)
解决方案:在项目中导入全局的ajax请求,如下
$(function() {
//处理session失效无法跳转到登录页面的问题
$.ajaxSetup({
complete:function(XMLHttpRequest,textStatus){
if(textStatus=="parsererror"){
window.location.href = '/CIB/login';
}
}
})
});
网友评论