发布表单时的 post 与 put
当评估表单是否已提交时,我检查方法是否为 post,而不是 get。有人告诉我,这是一个好方法,可以了解表单是通过单击“提交”按钮提交的,而不仅仅是由在 url 中传递数据的脚本提交的。
“put”方法怎么样?看起来和“post”很相似。是否可以或多或少地用它来代替“邮寄”而不损失“邮寄”所提供的好处呢?
When evaluating that a form was submitted, I check that the method was post, not get. I was told this is a good way to know that the form was submitted by clicking the submit button and that it's not just being submitted by a script that's passing the data in the url.
How about the "put" method. It seems very similar to "post". Can it be more or less be used instead of "post" without much loss in the benefits provided by "post"?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
不可以。
HTML 仅支持
post
和 < code>get 作为表单方法,尽管 HTTP 还有其他方法。即使在 HTML 表单的上下文之外,答案仍然是否定的,因为 PUT 和 POST 非常不同。 POST 是一个通用的“这是一些数据,用它做一些事情”方法,而 PUT 的意思是“用这个数据替换这个 URI 上的资源”。
No.
HTML only supports
post
andget
as form methods, even though HTTP has others.Even outside the context of an HTML form, the answer is still no as PUT and POST are very different. POST is a generic "Here is some data, do something with it" method, while PUT means "Replace the resource at this URI with this data".
如果您这样做是出于安全原因,则
GET
或POST
并不重要。阅读有关 XSRF 预防的 Wikipedia 文章:http://en.wikipedia.org/wiki/Cross -site_request_forgery#预防If you're doing it for security reasons,
GET
orPOST
doesn't matter. Read the Wikipedia article on XSRF prevention: http://en.wikipedia.org/wiki/Cross-site_request_forgery#Preventionput 和 post 在安全方面没有什么区别......
但某些服务不支持 put
there is no different between put and post in security ...
but put is not supported in some of service's