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

时间:2011-06-21 13:03:07

标签: javascript jsp browser spring-mvc

在我的JSP页面中,我在提交页面时使用post方法。 所以,一旦我从第1页转到第2页。在第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。

那么response.sendRedirect Fit。

在哪里

4 个答案:

答案 0 :(得分:3)

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

答案 1 :(得分:1)

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

但是,会话到期后,用户将无法按“刷新”。此外,它将打破多窗口。用户将无法在单独的窗口中执行2个不同的提交,因为它们将共享相同的会话对象。

答案 2 :(得分:1)

 <?php

 session_start();

 if(!isset($_SESSION['disablethispage'])){
 $_SESSION['disablethispage'] = true;
 // serving the page first time

 }else{
 // visited before or page was refreshed

 }

 ?>

答案 3 :(得分:0)

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

http://plungjan.name/testredirect.html - &gt; redirect.php - &gt; thanks.html

这里是redirect.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..

相关问题