GetMapping和PostMapping和RequestMapping区别
·
-
三者的关系图

-
作用
@RequestMapping、@PostMapping、@GetMapping均为映射请求路径,可作用于类或方法上。当作用于类时,是该类中所有响应请求方法地址的父路径。 -
示例
@RequestMapping("/test") //test即父路径
public class test {
@RequestMapping(value = "/hello", method = RequestMethod.GET)
// @GetMapping("/hello")
@ResponseBody // 将返回的java对象转为json格式的数据
public String hello() {
return "hello world !";
}
}
访问路径:http://localhost:8080/test/hello
更多推荐

所有评论(0)