String requestType = request.getHeader("X-Requested-With");
if (!StringUtils.isEmpty(requestType) && requestType.equalsIgnoreCase("XMLHttpRequest")) {
response.setHeader("sessionStatus", "timeout");
response.sendError(518, "session timeout.");
}
//定义ajax全局事件
$(document).ajaxError(function(jqxhr, error) {
var sessionStatus = error.getResponseHeader("sessionStatus");
if (sessionStatus == "timeout") {
$.MsgBox.Alert("系统提示", "您的登录信息已过期,请重新登录!", function(){
top.location.href = "${pageContext.request.contextPath}";
})
}
var operationStatus = error.getResponseHeader("operationStatus");
if (operationStatus == "refused") {
$.MsgBox.Alert("系统提示", "您没有权限执行该操作!", function(){
top.location.href = contextPath;
})
}
});