【问题标题】:"Webpage has expired" in Spring Framework MVCSpring Framework MVC 中的“网页已过期”
【发布时间】:2017-02-03 10:13:15
【问题描述】:

我有一个基于 Spring Web 模型-视图-控制器 (MVC) 框架的项目。 Spring Web 模型-视图-控制器 (MVC) 框架的版本是 3.2.8,部署在 WebLogic Server 版本上: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"; 

【问题讨论】:

    标签: java spring http spring-mvc internet-explorer


    【解决方案1】:

    只要设置方法form方法为get,点击提交按钮时,改为post即可

    【讨论】:

      【解决方案2】:

      如果您发出任何 POST 请求,浏览器将始终显示“网页已过期”。如果您刷新页面 POST 请求再次提交所有参数,因此只有在您有表单要提交或无法在 url 中发送的内容时才使用 POST 请求。

      1) 将所有正常请求转换为 GET 请求,并仅将提交请求保留为 POST 请求。

      【讨论】:

      • 是我按照@En Lopes de Plats Bruts 的建议所做的,但似乎我仍然有 smae 问题
      【解决方案3】:

      将此标签添加到您的 html 页面:

      &lt;meta http-equiv="Cache-control" content="public"&gt;

      更多信息在这里:https://support.microsoft.com/en-us/help/183763/error-message-warning-page-has-expired-the-page-you-requested...

      【讨论】:

        【解决方案4】:

        您处理的问题是浏览器的导航遵循独立于您的 webapp 逻辑的一般规则。

        没有解决这个问题的通用方法,但您可以使用 javascript 更改导航历史,使其符合您的逻辑。

        您实际上可以替换历史记录的顶部元素,这样您的历史记录中就没有帖子了。

        answer 有一个很好的例子。

        【讨论】:

          【解决方案5】:

          实际上这是一个与缓存相关的问题。可以通过以下方式解决。

          建议#1

          BalusC 通过使用过滤器给出了解决方案。无需添加所有 jsp 文件。它会减轻你的痛苦。

          要禁用 JSP 页面的浏览器缓存,请创建一个过滤器,它是 映射在 *.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

          建议#2

          在你的jsp文件中,你可以添加。它会解决你的问题。

          <%
              response.setHeader("Cache-Control", "no-cache");
              response.setDateHeader("Expires", 0);
          %>
          

          资源链接:

          Add an Expires or a Cache-Control header in JSP

          建议#3

          微软支持页面给出了浏览器相关的解决方案,如下所示

          1. 您可以刷新页面重新提交。
          2. 要解决此问题,请禁用“不保存加密 pages to disk”选项,或获取并安装最新版本的 Internet Explorer。

          资源链接:Solution for Error Message: Warning: Page Has Expired: The Page You Requested

          【讨论】:

            猜你喜欢
            • 2013-04-02
            • 1970-01-01
            • 1970-01-01
            • 2011-01-20
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 2014-06-25
            • 2013-04-28
            相关资源
            最近更新 更多