Spring Boot in several requests to talk about the annotation parameters

We know that in the daily development process, whether traditional ssm project, or spring boot project from the front end of the parameters passed to it, I need to process parameters, here are a few notes on the request parameters in spring boot project, several major: @ Param, @ PathVariable, @ RequestParam, @ requestBody, there is a comment made on the date of processing @Jsonformat

@Param

The notes said that when there are multiple parameters we pass the time, if not this parameter to add notes, then the sql statement xml file mybatis of the parameters will have to be written arg0, arg1, arg2 ... etc., or param1, param2, param3 ... and so on, added this comment, specify the name in the annotation parameters, then the sql statement xml file can be specified with a name
below to see how to use specific
Here Insert Picture Description
Here Insert Picture Description

@PathVariable

This represents the annotation request url placeholder parameter passed in the front end, for example, {id} corresponding processor parameter binding
we url passed in front end
Here Insert Picture Description
rear end of the process parameters
Here Insert Picture Description

@RequestBody

This annotation indicates json data received from the front end of transfer, the data in json requesting entity, since it is then the requesting entity, at the front end transmission mode can not get a way, it is necessary with the post, and RequestParam simultaneously requestBody use, but RequestBody parameters can only be used once, and RequestParam can be used in different parameters
Here Insert Picture Description
Here Insert Picture Description

@RequestParam

The annotation data indicative of the distal end is passed before the key / value pairs, a plurality of parameters RequestParam annotations
Here Insert Picture Description
Here Insert Picture Description

@JsonFormat

When we time the database is passed from the rear end to the front end of show, the distal end will resolve discrepancies date, no add, in this case we may correspond with the data entity class field in the database corresponding to above this annotation, and specify date format in the database can be consistent
Here Insert Picture Description
Here Insert Picture Description

Published 207 original articles · 87 won praise · views 50000 +

Guess you like

Origin blog.csdn.net/zhouym_/article/details/100113131