问题:就是我在登陆后的一个页面,然后我点击注销,就返回到我登陆的页面.但是我在浏览器上点后退一步就到我登陆后的页面,然后刷新,又能在登陆后的页面上进行操作.
而我想刷新后,自动到我的登陆的页面,而不是登陆后的页面,并不能进行操作.有什么办法能解决.急!!!!!
而我想刷新后,自动到我的登陆的页面,而不是登陆后的页面,并不能进行操作.有什么办法能解决.急!!!!!
调试欢乐多
public class SessionTimeoutCheckFilter implements Filter { private Logger logger = Logger.getLogger(this.getClass()); private FilterConfig filterConfig;
private String sessionNotCheckUrls[];// 不进行Session检查的URL public void init(FilterConfig arg0) throws ServletException {
this.filterConfig = arg0;
String notCheckUrls = filterConfig.getInitParameter("notCheckUrls");
if (notCheckUrls != null && notCheckUrls.length() > 0)
sessionNotCheckUrls = notCheckUrls.split(",");
} public void doFilter(ServletRequest srequest, ServletResponse sresponse,
FilterChain chain) throws IOException, ServletException {
HttpServletRequest request = (HttpServletRequest) srequest;
HttpServletResponse response = (HttpServletResponse) sresponse;
HttpSession session = request.getSession(true);
String requestUri = request.getServletPath();
String param = request.getQueryString(); // 参数
if (param != null && param.length() != 0)
requestUri = requestUri + "?" + param; if (requestUri.substring(requestUri.length() - 1).equals("/"))// ip+projectName请求
requestUri = Defines.LOGIN_PAGE; boolean needCheck = true;
for (int i = 0; i < sessionNotCheckUrls.length; i++) {
String checkURL = sessionNotCheckUrls[i];
if (requestUri.lastIndexOf(checkURL) != -1) {
needCheck = false;
break;
}
}
if (needCheck && session.getAttribute(Defines.S_USERINFO) == null) {
String loginPage = request.getContextPath() + "/"
+ Defines.LOGIN_PAGE;
session.setAttribute(Defines.S_LAST_ACCESS_PAGE, requestUri);
logger.info("用户会话无效,请求被重置! PATH:" + requestUri);
StringBuffer sb = new StringBuffer("<script>");
sb.append("alert('提示:用户未登陆或连接超时,请重新登陆!');");
sb.append("window.top.location.href='");
sb.append(loginPage);
sb.append("';</script>");
response.setContentType("text/html; charset=GBK");
response.getWriter().print(sb.toString());
return;
}
chain.doFilter(request, response);
} public void destroy() {
this.filterConfig = null;
} public FilterConfig getFilterConfig() {
return filterConfig;
} public void setFilterConfig(FilterConfig filterConfig) {
this.filterConfig = filterConfig;
}}
可以嵌在一个JSP页面当中:
session.invalidate();
out.print("<script>alert('您已经成功注销系统,谢谢您的使用!');top.close();</script>");
可以嵌在一个JSP页面当中:
session.invalidate();
out.print("<script>alert('您已经成功注销系统,谢谢您的使用!');top.close();</script>");
像其他网站一般都用 ajax 来处理 或者 登录通行证 也是遇到相同问题