注销后不要回到jsp中的上一页

man*_*chu 3 javascript jsp

为防止用户在注销后返回,我在home.jsp页面中使用了以下代码

<% 
if (session.getAttribute("authe") != null && session.getAttribute("authe").equals(true)) {

}
else {  
    response.sendRedirect("login.jsp");
}
%>
Run Code Online (Sandbox Code Playgroud)

我使会话无效logout.jsp.

它工作正常但是当我在注销后按下后退按钮它仍然进入主页但是在重新加载该主页后它移动到登录页面.我认为这是由于浏览器的默认操作.

如何让它有效地工作?

Har*_*nti 6

home.jspput标题中no-cache:

<%
   response.addHeader("Cache-Control", "no-cache,no-store,private,must-revalidate,max-stale=0,post-check=0,pre-check=0"); 
   response.addHeader("Pragma", "no-cache"); 
   response.addDateHeader ("Expires", 0);
 %>
Run Code Online (Sandbox Code Playgroud)