@RestController和@GetMapping

@RestController 可以代替@Controller使用,使用了@RestController的控制器默认所有请求方法都用了@ResponseBody注解。

 

@GetMapping("oneName") 与@RequestMapping(value = "oneName", method = RequestMethod.GET)等价。

 

@PostMapping、@PutMapping等,同理。

 

为了使代码简洁一点,以后优先使用@RestController和@GetMapping。

 

posted @ 2018-01-04 21:58  Deolin  阅读(1210)  评论(0编辑  收藏  举报