我習慣于在 C# Web API 中進行開發,除了單個端點的路由屬性之外,我還可以為控制器添加前綴,例如,
[RoutePrefix("/MyController")]
但是,我正在使用 Java Spring Boot 進行開發,雖然我可以映射單個端點,但我找不到為所有人添加前綴的方法。
這可能嗎?
uj5u.com熱心網友回復:
在 spring-boot 上,您可以@RequestMapping("/MyController")在類級別使用注釋。
@RequestMapping("/MyController")
public class MyController {
@GetMapping(value = "/helloWord") // this will become /MyController/helloWord
public String helloWorld() {
return "Hello World";
}
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/528232.html
標籤:爪哇弹簧MVC路线
