I'm used to developing in C# Web API where as well as routing attributes for individual endpoints I can also add a prefix for the controller, e,g,
@RoutePrefix("/MyController")
However I'm developing in Java Spring Boot and although I can map individual endpoints, I can't find a way to add a prefix for all.
Is this possible?
CodePudding user response:
On spring-boot you can use the @RequestMapping("/MyController")
annotation at the class level.
@RequestMapping("/MyController")
public class MyController {
@GetMapping(value = "/helloWord") // this will become /MyController/helloWord
public String helloWorld() {
return "Hello World";
}
}