“确认重新提交表格”问题。 MVC servlet JSP javabean

发布于 2024-10-06 15:37:12 字数 128 浏览 0 评论 0原文

嘿伙计们!为什么每次我点击网站上的某些内容并尝试返回一页时,它都会显示“确认表单提交”。我正在运行本地服务器。这与 Facebook 等其他网站形成鲜明对比,在 Facebook 等网站上,我可以返回页面,而不会出现要求我刷新页面的烦人消息。

hey guys! why is it that everytime i click something on my website and try to go back one page, it says "Confirm Form Submission". Im running a local server. This is in contrast to other websites like facebook where i can go back a page without that annoying message asking me to refresh the page.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

多像笑话 2024-10-13 15:37:12

确实很好的解释:

由于网络开发人员的草率编码实践,浏览器被迫添加此消息。场景如下:

1)用户填写表单并提交(帖子表单)

2) 服务器处理发布数据并响应一个标记为不可缓存的新页面(确认)

3) 用户导航到新页面。

4)用户按返回:

浏览器要显示步骤2中的页面,由于其标记为无缓存,因此必须向服务器请求,即重新发布数据(执行步骤1)。这是草率编码的情况,如果这是信用卡收费,并且服务器上没有重新发布检测,则该卡会被收取两次费用。这是一个非常常见的问题,浏览器必须检测到这一点并警告用户。

最佳修复是在第二步中,服务器将重定向发送到确认页面。那么当用户通过历史记录或返回访问确认时,它是一个 get 请求,而不是 post 请求,并且不会显示警告。

来源:http://forums.asp.net/p/1553589/3814773.aspx

Nice Explanation indeed :

Because of the sloppy coding practices of web developers browsers were forced to add this message. the scenario is as follows:

1) user fills in form and submits (posts form)

2) the server process the post data and responds with a new page (confirm) marked as not cacheable

3) the user navigates to a new page.

4) the user press back:

for the the browser to display the page in step 2, because its marked no-cache, it must request it from the server, in other words do the repost of the data (do step 1). here is were the sloppy coding came in, if this was an credit card charge, and repost detection was not on the server, the card is charged twice. this was (is) so common a problem, that the browsers had to detect this and warn the users.

the best fix is in step two, the server sends a redirect to the confirm page. then when the user accesses the confirm via history or back, its a get request, not a post request and will not show the warning.

source : http://forums.asp.net/p/1553589/3814773.aspx

眼眸里的那抹悲凉 2024-10-13 15:37:12

好吧,别介意人们。显然我到处都使用 POST 方法。将其更改为 GET 可以解决问题。我认为这与缓存有关..

okay nevermind people. apparently i was using POST method everywhere. changing it to GET solves the problem. I think it has something to do with caching..

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文