Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想在我的项目中销毁一个会话,这样当我点击注销时,它会转到一个页面 "KillSession.jsp" ,在那个文件中我写了 "session.invalidate();" 然后我将用户重定向到登录页面。但是,如果我使用浏览器上的后退按钮,即使我已注销,它也会返回到我之前访问过的页面。该怎么办?
您的浏览器缓存它,您需要添加标题以强制您的浏览器不强制它
确保在注销之前不缓存最后一页。您可以执行以下操作:
response.setHeader("Cache-Control","no-cache,no-store,must-revalidate"); response.setHeader("Pragma","no-cache"); response.setDateHeader("Expires", 0);