问题描述
- Symfony2为实体提供了删除表单
- 用户选择删除按钮
- Symfony2控制器将删除实体并将用户重定向至确认页面
- 如果用户选择浏览器后退按钮,他/她再次查看记录和删除表单
- 选择删除按钮会抛出一个异常,因为它已被删除
避免后退按钮和重新提交的最佳方法是什么?
此问题的控制器与 所有数据更改请使用 Let's consider a scenario like below : What is the best way to avoid back button and re-submissions ? The controller for this question is the same as here. All data changing requests should be done using the 这篇关于如果选择浏览器后退按钮,如何避免表单重新提交?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! POST
方法 - 或 PUT
, POST
或 DELETE
,如果您使用RESTful方式执行此操作。在这样的请求之后,重定向到 GET
页面。如果用户按下后退按钮,浏览器将显示一条警告,说明请求应该再次发送,并且可能导致不需要的结果。如果用户坚持重新发送请求,她应该得到一个 404
错误页面,因为她正在尝试使用一些不存在的东西。POST
method — or PUT
, POST
or DELETE
if you're doing it in the RESTful way. After such a request, redirect to a GET
page. If a user will push the back button, the browser will show a warning saying that the request should be sent again and that it can lead to unwanted results. If the user insists on resending the request, she should get a 404
error page because she's trying to do stuff with something that doesn't exist anymore.