- @Controller:用于定义控制器类
- @ResponseBody:表示方法的返回结果直接写入HTTP response body中
- @PathVariable:获取路径参数
- @RequestParam:用在方法的参数前面
- @RequestBody:请求的json转化为bean去接收
- @RestController:是@Controller和@ResponseBody的合集
- @RequestMapping:提供路由信息,负责URL到Controller中的具体函数的映射
- @GetMapping:是@RequestMapping(method = RequestMethod.GET)的缩写。不支持@RequestMapping的自定义属性。
- @PostMapping:是@RequestMapping(method = RequestMethod.POST)的缩写。不支持@RequestMapping的自定义属性。
- @ControllerAdvice:统一处理异常。
- @ExceptionHandler:用在方法上表示遇到这个异常就执行以下方法。