Spring Boot 下的 SpringMVC 的使用方式与单独使用SpringMVC其实是相同的
-
@Controller
-
即为
Spring MVC
的注解,处理http
请求
@RestController
-
Spring4
后新增注解,是@Controller
与@ResponseBody
的组和注解,用于返回字符串或者json
数据
@GetMapping
- 等价于@RequestMapping(method = RequestMethod.Get ) @PostMapping
- 等价于@RequestMapping(method = RequestMethod.Post) @PutMapping
- 等价于@RequestMapping(method = RequestMethod.Put) @DeleteMapping
- 等价于@RequestMapping(method = RequestMethod.Delete)