概况
PUT与POST 基本区别反映在Request-URI 的不同意义,PUT 是属于幂等性的方法,提交相同的内容不管提交几次返回的内容都相同,而POST 方法不具有这一属性。
例如:某张表的数据库主键设置了自增属性, 当提交数据的时候服务器都会创建一条新的记录,那么是不能使用PUT 方法来对此资源进行操作的。
HTTP/1.1 规范 (RFC2616) 第九章 9.1 提到了两个概念:Safe Methods 和 Idempotent Methods , 其中
Idempotent Methods( 幂等方法) 定义
<span style="font-size:14px;">Methods can also have the property of "idempotence" in that (aside from error or expiration issues) the side-effects
of N > 0identical requests is the same as for a single request.
The methods GET, HEAD, PUT and DELETE share this property. Also, the methods OPTIONS and TRACE SHOULD NOT have
side effects, and so are inherently idempotent