今天客户说服务器重启日志就有空指针错误,经研究是session过期而客户前台界面未刷新继续发送ajax请求导致,ajax走fiter session为空时不会重定向,解决思路filter继续返回错误界面,easyui datagrid onLoadError做判断
filter代码,很粗糙
if (hRequest.getSession().getAttribute(SOperationResource.SESSION_USER) == null) { PrintWriter out = hResponse.getWriter(); out.println("<html>"); out.println("<script>"); out.println("window.open('" + request.getServletContext().getContextPath() + "/index.html','_top');"); out.println("</script>"); out.println("</html>"); return; }
datagrid端:onLoadError:function(data){ if(data.responseText.toString().indexOf("账户")){ location.href="../index.html" } },原文链接:https://www.f2er.com/ajax/162903.html