1 @JsonIgnore
作用:在实体类向前台返回数据时用来忽略不想传递给前台的属性或接口。
Eg:User实体中会有字段password字段,当返回用户信息给前台的时候,当然是不希望将password值也一并返回。
所以,这个时候可以在password属性上加上注解JsonIgnore或者,可以在User类上加上注解@JsonIgnoreProperties(value = "{password}")
ref: https://blog.csdn.net/fakerswe/article/details/78626085
2 @PathVariable
从名字可以简单理解:路径变量,@PathVariable是spring3.0的一个新功能:接收请求路径中占位符的值
@PathVariable("xxx")
通过 @PathVariable 可以将URL中占位符参数{xxx}绑定到处理器类的方法形参中@PathVariable(“xxx“)
ref: https://blog.csdn.net/sswqzx/article/details/84194979
ref: https://www.cnblogs.com/williamjie/p/9139548.html
3 @RequestParam
@RequestParam 和 @PathVariable 注解是用于从request中接收请求的,两个都可以接收参数,
区别:@RequestParam 是从request里面拿取值,而 @PathVariable 是从一个URI模板里面来填充
URL:
http://localhost:8080/springmvc/hello/101?param1=10¶m2=20
使用@RequestParam注解:
@RequestMapping("/hello/{id}")
public String getDetails(@PathVariable(value="id") String id,
@RequestParam(value="param1", required=true) String param1,
@RequestParam(value="param2", required=false) String param2){
.......
}
ref: https://blog.csdn.net/u011410529/article/details/66974974
4 @GetMapping、@PostMapping、@PutMapping、@DeleteMapping、@PatchMapping
Spring4.3中引进了{@GetMapping、@PostMapping、@PutMapping、@DeleteMapping、@PatchMapping}
来帮助简化HTTP映射 并更好地表达被注解方法的语义
ref: http://www.mamicode.com/info-detail-2790738.html
PS: 持续更新。。。
原文:https://www.cnblogs.com/caesar-the-great/p/12834337.html