在开发中遇到这样的问题:表单在提交后,点击浏览器的后退按钮,又回到原来的表单页面。现想实现在点后退时提示页面过期的效果,实现方式如下:
1.在要禁止缓存的页面<head>中加以下脚本:
<meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0">
2.在要禁止缓存的页面<head>中加以下脚本:
<%
response.setHeader("Cache-Control","no-cache");
response.setHeader("Pragma","no-cache");
response.setDateHeader ("Expires", 0);
%>
本文介绍了一种防止表单提交后返回时被浏览器缓存的方法。通过在表单页面的头部添加特定的元标签及服务器响应头设置,可以有效地避免用户在提交表单后通过后退按钮回到未更新的表单页面。

2万+

被折叠的 条评论
为什么被折叠?



