@RestController和@GetMapping

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

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

@PostMapping、@PutMapping等,同理。

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

原文地址:https://www.cnblogs.com/deolin/p/8196246.html