Spring Boot在Controllder中常用注解

1.@RestController

@RestController 相当于@Controller+@ResponseBody 注解
如果使用@RestController 注解Controller 中的方法无法返回页面,相当于在方法上面自
动加了@ResponseBody 注解, 所以没办法跳转并传输数据到另一个页面, 所以
InternalResourceViewResolver 也不起作用,返回的内容就是Return 里的内容。

2@GetMapping
@GetMapping 注解是@RequestMapping(method = RequestMethod.GET)的缩写。


3@PostMapping
@PostMapping 注解是@RequestMapping(method = RequestMethod.POST)的缩写。


4@PutMapping
@PutMapping 注解是@RequestMapping(method = RequestMethod.PUT)的缩写。


5@DeleteMapping
@DeleteMapping 注解是@RequestMapping(method = RequestMethod.DELETE)的缩写。

posted @ 2020-05-08 13:28  郑金圣  阅读(263)  评论(0编辑  收藏  举报