我有一个基于Spring Web模型 - 视图 - 控制器(MVC)框架的项目。在WebLogic Server版本上部署的Spring Web模型 - 视图 - 控制器(MVC)框架的版本为3.2.8:12.1.2.0.0
我在1 JSP中有这个表单
<form:form commandName="deviceForm"
name="deviceForm"
id="deviceFormId"
method="post"
action="${contextPath}/device/${deviceForm.device.id}"
htmlEscape="yes"
enctype="multipart/form-data">
我使用POST方法做了几个动作..之后我使用浏览器(IE11)后退按钮,我收到了这个错误
Webpage has expired
Most likely cause:
•The local copy of this webpage is out of date, and the website requires that you download it again.
Something to try:
Click on the Refresh button on the toolbar to reload the page. After refreshing, you might need to navigate to the specific webpage again, or re-enter information.
More information More information
If you continue to have this problem, try the following:
1.In Internet Explorer, click the Tools button , click Internet Options, and then click the Advanced tab.
2.Scroll down and clear the “Do not save encrypted pages to disk” option in the Security settings.
我也尝试在POST方法中重定向
response.setStatus(HttpServletResponse.SC_SEE_OTHER );
response.setHeader("Location", /device/" + device.id");
response.setHeader("Connection", "close");
response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); // HTTP 1.1.
response.setHeader("Pragma", "no-cache"); // HTTP 1.0.
response.setHeader("Expires", "0"); // Proxies.
return "redirect:/device/" + device.id";
答案 0 :(得分:3)
只需将方法表单方法设置为get,当您单击提交按钮时,只需将其更改为post
答案 1 :(得分:0)
如果您发出任何POST请求,浏览器将始终显示“网页已过期”。如果刷新页面POST请求再次提交所有参数,那么只有当您有要提交的表单或无法通过URL发送的内容时才使用POST请求。
1)将所有正常请求转换为GET请求,并仅保留提交请求作为POST请求。
答案 2 :(得分:0)
将此标记添加到您的html页面:
<meta http-equiv="Cache-control" content="public">
答案 3 :(得分:0)
您要处理的问题是从浏览器导航遵循一般规则,这些规则独立于您的webapp逻辑。
没有一般方法可以解决此问题,但您可以使用javascript更改导航历史记录,使其与您的逻辑相匹配。
您实际上可以替换历史记录的顶部元素,以便历史记录中没有帖子。
这个answer就是一个很好的例子。
答案 4 :(得分:0)
实际上这是一个与缓存相关的问题。您可以通过以下方式解决。
BalusC通过使用过滤器给出了解决方案。无需添加所有jsp文件。它会减少你的痛苦。
要禁用JSP页面的浏览器缓存,请创建一个Filter 映射在* .jsp的url-pattern上,基本上执行以下操作 doFilter()方法:
HttpServletResponse httpResponse = (HttpServletResponse) response; httpResponse.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); // HTTP 1.1 httpResponse.setHeader("Pragma", "no-cache"); // HTTP 1.0 httpResponse.setDateHeader("Expires", 0); // Proxies.
这样您就不需要在所有JSP页面上进行复制 用scriptlet弄乱它们。
要为CSS和JS等静态组件启用浏览器缓存,请执行 它们都在像/ static或/ resources这样的公共文件夹中并创建一个 映射在/ static / *或/ resources / *的url模式上的过滤器 并在doFilter()方法中基本执行以下操作:
httpResponse.setDateHeader("Expires", System.currentTimeMillis() + 604800000L);
资源链接:https://stackoverflow.com/a/3055297
在您的jsp文件中,您可以添加。它将解决您的问题。
<%
response.setHeader("Cache-Control", "no-cache");
response.setDateHeader("Expires", 0);
%>
资源链接:
Add an Expires or a Cache-Control header in JSP
Microsoft支持页面提供了与浏览器相关的解决方案,如下所示
资源链接:Solution for Error Message: Warning: Page Has Expired: The Page You Requested