PUT and POST difference

POST is used to submit the data. The data submitted in the HTTP request body's aim and data submitted to the server storage, without allowing the user to change too much the corresponding data (mainly with respect to a lot of trouble to modify the url). 
PUT operation is idempotent. The so-called idempotent means that no matter how many operations, the results are the same. For example, I used to modify PUT an article, and then doing the same operation, the result of each operation is no different
POST operation is neither safe nor idempotent, such as common POST repeated loading problem: When we repeatedly after issuing the same pOST request, the result is to create a number of resources.
  Meaning safe and idempotent that: when the operation does not achieve the desired objectives, we can not stop retried without resources have side effects. In this sense, POST operations tend to be harmful, but many times we had to use it.
  Another point to note is that you can use to create operations POST, PUT can be used, the difference is that POST action on a set of resources (/ articles), and PUT operations are in effect on a specific resource (/ articles / 123),
then popular point that, if the URL can be determined at the client, then use PUT, if it is determined at the server, then use POST, for example, a lot of resources using a database auto-increment primary key as identification information, and create identification information of resources in the end what can only be provided by the server, this time it must use POST.

Guess you like

Origin www.cnblogs.com/findbetterme/p/11432630.html