用户退出和退出后按后退按钮又可以操作的问题
用户退出解决办法:
在JSP里写
Html代码
<html:button property="PassWordBackOutButton" ="PassWordBackOutJava();">退出</html:button>
VehicleDriveManageInterfaceBackOutJava()
{
location.href = "BackOut.jsp" ;
}
<html:button property="PassWordBackOutButton" ="PassWordBackOutJava();">退出</html:button>
VehicleDriveManageInterfaceBackOutJava()
{
location.href = "BackOut.jsp" ;
}
BackOut.jsp为我定义的清空session的代码,代码如下:
Html代码
<%
session.invalidate(); //这行为清空session
response.sendRedirect("UserLogin.jsp");//这行为转到的页面,我设置转到登陆页面
%>
<%
session.invalidate(); //这行为清空session
response.sendRedirect("UserLogin.jsp");//这行为转到的页面,我设置转到登陆页面
%>
好,用户退出功能完成,可是退出之后,按下后退按钮,看到了登陆时看过的页面,试着往文本框里输入了值,点提交,汗,提交成功了,这个是大事了,开始找解决办法,找来找去,暂时只有禁止缓存了,禁止缓存的方法为:
在想禁止缓存的页面的<body></body>里加入:
Html代码
<%
response.setHeader("Pragma","No-cache");
response.setHeader("Cache-Control","no-cache");
response.setDateHeader("Expires",0);
%>
<%
response.setHeader("Pragma","No-cache");
response.setHeader("Cache-Control","no-cache");
response.setDateHeader("Expires",0);
%>
即
Html代码
:<body>
<%
response.setHeader("Pragma","No-cache");
response.setHeader("Cache-Control","no-cache");
response.setDateHeader("Expires",0);
%>
</body>
:<body>
<%
response.setHeader("Pragma","No-cache");
response.setHeader("Cache-Control","no-cache");
response.setDateHeader("Expires",0);
%>
</body>
如果不管用,可以在Filter里也加上
Java代码
esponse.setHeader("Pragma","No-cache");
response.setHeader("Cache-Control","no-cache");
response.setDateHeader("Expires",0);
esponse.setHeader("Pragma","No-cache");
response.setHeader("Cache-Control","no-cache"); &nb
相关新闻>>
- 发表评论
-
- 最新评论 更多>>