@PathVariable

当使用@RequestMapping URI template 样式映射时, 即 someUrl/{paramId}, 这时的paramId可通过 @Pathvariable注解绑定它传过来的值到方法的参数上。
例:

  1. @Controller
  2. @RequestMapping("/owners/{ownerId}")
  3. public class RelativePathUriTemplateController {
  4. @RequestMapping("/pets/{petId}")
  5. public void findPet(@PathVariable String ownerId,@PathVariable String petId, Model model) {
  6. // implementation omitted
  7. }
  8. }

@RequestParam

获取通过get方式获得的参数,如果前端传入的参数名与该参数名一样,可以省略不写。
@RequestParam的required参数默认为true,即代表该参数为必传项,如果省略不写@RequestParam,就为非必传项

@RequestBody、@RequestHeader

获取通过post方式获得的参数,不可省略,分别代表请求头、请求体中的键值对

@ApiParam(value = “注释”,required = true)

为swagger的api文档提供注释解释参数

@valid

检验参数是否符合要求,要求在该常数中的类中通过注解定义,如@NotNull等