据我所知,有三种类型:

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

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


当前回答

1.3 HTTP GET / POST选择快速检查

在以下情况下使用GET:

    The interaction is more like a question (i.e., it is a safe operation such as a query, read operation, or lookup).

在以下情况下使用POST:

    The interaction is more like an order, or
    The interaction changes the state of the resource in a way that the user would perceive (e.g., a subscription to a service), or
    The user be held accountable for the results of the interaction.

源。

其他回答

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

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

简单版本的POST GET PUT DELETE

使用GET -当你想获得任何资源,如基于任何Id或名称的数据列表 使用POST -当你想发送任何数据到服务器。请记住POST是一个重量级操作,因为对于更新,我们应该使用PUT而不是POST POST将创建新的资源 使用PUT -当你

Gorgapor, mod_rewrite仍然经常使用GET。它只是允许将一个更友好的URL转换为一个带有GET查询字符串的URL。

1.3 HTTP GET / POST选择快速检查

在以下情况下使用GET:

    The interaction is more like a question (i.e., it is a safe operation such as a query, read operation, or lookup).

在以下情况下使用POST:

    The interaction is more like an order, or
    The interaction changes the state of the resource in a way that the user would perceive (e.g., a subscription to a service), or
    The user be held accountable for the results of the interaction.

源。

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