class级和方法级之间的RequestMapping继承
RequestMapping inheritence between class level and method level
鉴于下面的 @Controller
,即使我向 webApp 发送 Get 请求,控制器 运行 主页方法。
@RestController
@RequestMapping(method = RequestMethod.POST)
public class MyController {
@GetMapping("/hello")
public String homePage() {
return "Hello, It is my first application";
}
}
怎么会这样?通常,我将其限制在 class 级别。
您的 @GetMapping("/hello") 方法被选为最具体的方法,并启用 /hello
路径
的 GET 请求
This annotation can be used both at the class and at the method level. In most cases, at the method level applications will prefer to use one of the HTTP method specific variants @GetMapping
鉴于下面的 @Controller
,即使我向 webApp 发送 Get 请求,控制器 运行 主页方法。
@RestController
@RequestMapping(method = RequestMethod.POST)
public class MyController {
@GetMapping("/hello")
public String homePage() {
return "Hello, It is my first application";
}
}
怎么会这样?通常,我将其限制在 class 级别。
您的 @GetMapping("/hello") 方法被选为最具体的方法,并启用 /hello
路径
This annotation can be used both at the class and at the method level. In most cases, at the method level applications will prefer to use one of the HTTP method specific variants @GetMapping