@Controller
声明controller层,处理由DispatcherServlet分发的请求。
@RequestMapping
请求地址映射,作用于类和方法上。
常用属性
value属性:指定请求的实际地址
method属性:指定请求的method类型, GET、POST、PUT、DELETE等
@GetMapping
组合注解,相当于@RequestMapping(method = RequestMethod.GET)
@PostMapping
组合注解,相当于@RequestMapping(method = RequestMethod.POST)
@RequestParam
将请求参数绑定至方法参数,(get是查询字符串的key,post是提交表请求体的key)
@RequestBody
接收的是请求体里面的数据(post是提交表单需要的请求体)
@ResponseBody
声明响应体
@RestController
组合注解,同时具有@Controller和@ResponseBody的作用