這個問題困擾了我n久,之前的辦法是用js,現在終於找到瞭解決辦法了:
網上流行的版本:
<%
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.setHeader("Cache-Control", "no-store");
response.setDateHeader("Expires", 0);
%>
註:我是加在不希望讓瀏覽器緩衝的jsp中的,下面舉個我用的例子:
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
response.setHeader("Pragma", "No-cache");
response.setHeader("Cache-Control", "no-cache");
response.setHeader("Cache-Control", "no-store");
response.setDateHeader("Expires", 0);
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Expires" content="0">
<meta http-equiv="Cache-Control" content="no-cache">
<meta http-equiv="Cache-Control" content="no-store">
<meta http-equiv="Pragma" content="no-cache">
<title>列表頁</title>
<meta http-equiv="description" content="列出使用者以供操作">
</head>
<body>
<form name="manage" action="/user_manage/delUser" method="post">
<s:iterator value="list" status="user">
<input type="checkbox" name="user.delId"
value="<s:property value="id" />">
<s:property value="username" />
<s:property value="password" />
<br />
</s:iterator>
<a href=javascript:manage.submit();>刪除選中的使用者</a>
</form><br />
<a href="/logout">退出登入</a>
<s:debug></s:debug>
</body>
</html>