GET,POST,PUT,DELETE Usage and instructions
GET request
- GET The request will send a request for data to the database , To get information , It is usually used to query data , Do not make any changes to the server's data , newly added , Delete and other operations . It doesn't affect the content of the resource , That is, the request does not affect the data of the server . The same request sent multiple times should return the same result .
- GET The request will attach the parameters of the request to URL Back , This creates security problems , If the login interface of the system uses get request , You need to encrypt the parameters of the request .
- GET The request itself HTTP The agreement does not limit its URL size , But different browsers have different size and length restrictions .
POST request
- POST The request is to send data to the server , Make changes to the server's data , Often used for data submission , New operation .
- POST The request parameters of the request are all in the request body
- POST Request itself HTTP There is no limit to the size of the protocol , What limits it is the processing power of the server .
PUT request
- PUT The request is to send data to the server , Make changes to the server's data , Commonly used for data modification .
- PUT And POST Requests change the server's data as well , however PUT Focus on data modification operations ,POST Focus on the addition of data operations
- PUT Requests do not increase the type of data , That is to say, no matter how many times PUT operation , The amount of data doesn't change .
DELETE request
- DELETE The request is used to delete resources from the server
* Be careful : These different forms of request , It's just a normative definition , Is not to say that get The request cannot modify the server's data , It's just a norm , For example, you can make all requests through post Way to visit , There is no problem in implementing the function , It's just that it doesn't conform to the standard , It's better for us to code as much as possible .