什么时候应该在 Web 应用程序中使用 GET 而不是 POST? [英] When should one use GET instead of POST in a web application?

查看:25
本文介绍了什么时候应该在 Web 应用程序中使用 GET 而不是 POST?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

似乎坚持 POST 是可行的方法,因为它会产生干净的 URL.GET 似乎创建了冗长的令人困惑的 URL.POST 在安全性方面也更好.适合保护表单中的密码.事实上,我听说许多开发人员只将 POST 用于表单.我还听说很多开发人员根本就没有真正使用过 GET.

It seems that sticking to POST is the way to go because it results in clean looking URLs. GET seems to create long confusing URLs. POST is also better in terms of security. Good for protecting passwords in forms. In fact I hear that many developers only use POST for forms. I have also heard that many developers never really use GET at all.

如果 POST 具有这两个优点,那么为什么以及在什么情况下会使用 GET?

So why and in what situation would one use GET if POST has these 2 advantages?

GETPOST 有什么好处?

What benefit does GET have over POST?

推荐答案

你是对的,但是对于搜索页面等使用 get 会更好.您希望 URL 明显且可发现的地方.如果您查看 Google 的(或任何搜索页面),它会在末尾放置一个 www.google.com/?q=my+search,以便人们可以直接链接到搜索.

you are correct, however it can be better to use gets for search pages and such. Places where you WANT the URL's to be obvious and discoverable. If you look at Google's (or any search page), it puts a www.google.com/?q=my+search at the end so people could link directly to the search.

实际上,您使用 GET 的次数比您想象的要多得多.简单地返回网页是一个 GET 请求.还有 POST、PUT、DELETE、HEAD、OPTIONS,这些都用在 RESTful 编程接口中.

You actually use GET much more than you think. Simply returning the web page is a GET request. There are also POST, PUT, DELETE, HEAD, OPTIONS and these are all used in RESTful programming interfaces.

GET 与 POST 对安全性没有影响,除非您使用 HTTP/SSL,否则它们都是不安全的.

GET vs. POST has no implications on security, they are both insecure unless you use HTTP/SSL.

这篇关于什么时候应该在 Web 应用程序中使用 GET 而不是 POST?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆