About the situation @RequestBody sometimes receive reception sometimes can not, @ RequestParam when to use

Recently a little puzzled, in company with @RequestBody can parse json string sent by the front-end, but they are doing when the project will not receive always, reported 415 errors, then pondered for a moment, looked any different request body and found that different,

 

 This form is submitted, the format is like this, so the front desk can not add @RequestBody, otherwise they will not receive parameters, and the company passed the front desk when parameter is pass

 

Add comment must be told to be parsed and assigned to the received object parameter which, subsequent operation, there is @RequestBody body receiving a request parameter, and @ RequestParam received information in the request header, for words,

@ RequestParam is removed only from the address request parameter, i.e. only the username = admin & password = admin this parse the string parameter, this parameter can not extract the body of the request. (Further explanation can not understand: spring of RequestParam annotations received parameter from requestHeader, i.e. request header, i.e. in the url format xxx username = 123 & password = 456 , and RequestBody annotated received parameter is derived from? requestBody, i.e. the request body.)

It thus received argument, and certainly the way the request is a certain relationship, such as:

When given at will get request, reception parameters for the annotation background requestBody; in post request, reception parameters for the background comments also being given RequestParam. This time completely understand !!!!

Guess you like

Origin www.cnblogs.com/qiaohechen/p/12043765.html