用f5限制页面重新加载时的确认消息

Restrict confirm message on page reload with f5

本文关键字:加载 消息 确认 新加载 f5      更新时间:2023-09-26

在我的JSP页面中,我在提交页面时使用post方法。所以一旦我从第一页转到第二页。在第2页中,如果我按F5,我会收到警报

"To display this page, Firefox must send information that will repeat any action (such as a search or order confirmation) that was performed earlier."

我知道这个问题有点讽刺,但请给我一个想法。我无法将我的方法从POST更改为GET,因为我需要发送大量数据。

提前感谢。。。

编辑:在我的Page1.JSP中,我调用onClick函数,在该函数中,我将action称为"/page2servlet.do"。现在,在Java方面,我使用Spring Framework。使用MVC对象,我返回page2.jsp.

那么响应在哪里呢。sendRedirect Fit。

POST后重定向到第2页。您将不再收到提示。

执行POST后,保存会话所需的所有信息,并使用GET发送即时重定向到其他页面。然后在另一个页面上获取会话中需要的所有信息。

但是,会话到期后,用户将无法按"刷新"。此外,它还会破坏多窗口。用户将无法在单独的窗口中进行两次不同的提交,因为它们将共享同一会话对象。

 <?php
 session_start();
 if(!isset($_SESSION['disablethispage'])){
 $_SESSION['disablethispage'] = true;
 // serving the page first time
 }else{
 // visited before or page was refreshed
 }
 ?>

下面是一个替换下一页的版本:

http://plungjan.name/testredirect.html->重定向.php->谢谢.html

这是重定向.php

<meta http-equiv="refresh" content="3; url=http://plungjan.name/test/thanks.html">
<script>
location.replace("http://plungjan.name/test/thanks.html");
</script>
redirecting..