注销功能无法在后退按钮上工作

时间:2015-04-15 05:21:46

标签: jsp cookies spring-security

下面是我的jsp页面,退出后,当我点击后退按钮时,它会回到上一页。请帮帮我,告诉我哪里错了。

if (request.getSession(false) != null) {
    session.invalidate();
}
Cookie terminate = new Cookie(TokenBasedRememberMeServices.SPRING_SECURITY_REMEMBER_ME_COOKIE_KEY, null);
String contextPath = request.getContextPath();
terminate.setPath(contextPath != null && contextPath.length() > 0 ? contextPath : "/");
terminate.setMaxAge(0);
response.addCookie(terminate);



<c:redirect url="/welcome"/>

1 个答案:

答案 0 :(得分:0)

解决方案只是使用代码清除jsp中的缓存,jsp已包含在每个jsp中。

清除缓存的代码

<%
     response.setHeader("Cache-Control","no-cache"); //Forces caches to obtain a new copy of the page from the origin server
     response.setHeader("Cache-Control","no-store"); //Directs caches not to store the page under any circumstance
     response.setDateHeader("Expires", 0); //Causes the proxy cache to see the page as "stale"
     response.setHeader("Pragma","no-cache"); //HTTP 1.0 backward compatibility
 %>