The difference between PUT and POST?

Reference: The difference between PUT and POST in HTTP protocol

1、POST

It is used to submit a request and can update or create resources. It is non-idempotent. For
example:
in the user registration function, each submission is to create a user account, then use POST

2、PUT

It is used to send update resources to the specified URL. It is idempotent. For
example
, if the user changes the password, although the two required parameters of account name and user password are submitted, each submission only updates the user password, and each request All just overwrite the original value, now PUT

3. Scene

When it is necessary to modify a specific resource in an updated form,

  • If the URL corresponding to the update has the same result multiple times, use PUT
  • If the same content is submitted every time and the final result is inconsistent, use POST

Guess you like

Origin blog.csdn.net/weixin_43912756/article/details/108296622