据我所知,有三种类型:

不要使用GET和POST 不要使用POST而使用GET 你用哪一个都不重要。

我对这三种情况的假设正确吗?如果有,每个案例都有哪些例子?


当前回答

重要的一点是,你通过GET提交的任何东西都会通过URL被暴露。其次,正如Ceejayoz所说,URL的字符数量是有限制的。

其他回答

另一个区别是POST通常需要两个HTTP操作,而GET只需要一个。

编辑:我应该澄清一下——对于常见的编程模式。一般来说,用一个直接的HTML网页来回复一个POST是一个有问题的设计,原因有很多,其中之一就是在按下后退按钮时出现烦人的“您必须重新提交这个表单,您希望这样做吗?”

当您希望URL反映页面的状态时,请使用GET。这对于查看动态生成的页面非常有用,比如这里看到的页面。POST应该在表单中用来提交数据,就像我点击“POST Your Answer”按钮一样。它还生成了一个更干净的URL,因为它没有在路径后生成参数字符串。

POST可以移动大数据,而GET不能。

但一般来说,这不是关于GET的缺点,而是一种惯例,如果你想让你的网站/web应用程序表现良好。

看看http://www.w3.org/2001/tag/doc/whenToUseGet.html

如果您不介意请求被重复(即它不会改变状态),请使用GET。

如果操作确实改变了系统的状态,则使用POST。

从w3schools.com:

What is HTTP? The Hypertext Transfer Protocol (HTTP) is designed to enable communications between clients and servers. HTTP works as a request-response protocol between a client and server. A web browser may be the client, and an application on a computer that hosts a web site may be the server. Example: A client (browser) submits an HTTP request to the server; then the server returns a response to the client. The response contains status information about the request and may also contain the requested content. Two HTTP Request Methods: GET and POST Two commonly used methods for a request-response between a client and server are: GET and POST. GET – Requests data from a specified resource POST – Submits data to be processed to a specified resource

在这里我们区分主要的区别: