据我所知,有三种类型:

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

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


当前回答

从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

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

其他回答

从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

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

最初的目的是GET用于获取数据,而POST用于任何用途。我使用的经验法则是,如果我要向服务器发送任何东西,我就使用POST。如果我只是调用一个URL来获取数据,我会使用get。

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

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

当我不希望人们看到QueryString或当QueryString变大时,我使用POST。另外,文件上传需要POST。

不过,我不认为使用GET有问题,我将它用于简单的事情,其中将内容保留在QueryString上是有意义的。

使用GET将允许链接到POST无法工作的特定页面。

我的一般经验法则是,当您向服务器发出不打算改变状态的请求时使用Get。post是为更改状态的服务器请求保留的。