Jsp “后退”按钮上的注销功能不起作用

Jsp “后退”按钮上的注销功能不起作用,jsp,cookies,spring-security,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 = requ

下面是我的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"/>

得到了解决方案,只需使用代码清除每个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
 %>

首先,你为什么要自己注销?Spring Security应该为您处理此问题。第二,当执行返回操作时,您会在浏览器缓存中获取上一个页面,如果您不希望这样做,请通过添加适当的标题来禁用受保护页面的缓存。