Reputation: 121
I have a Spring Boot app running with application.properties:
server.contextPath=/ctx1
I would like to pick a few specific @Controller's @RequestMappings' and
configure them to use a
different contextPath or have them
map against the root "/" path
I have looked at @Configuration-ing a ServletRegistrationBean but that doesn't seem to work.
Mike
Upvotes: 2
Views: 4885
Reputation: 1475
server.contextPath
will add url prefix to all controller mappings. You can use @RequestMapping
in each controller to add their own mapping for each. Like this:
@RestController
@RequestMapping(path = "/demo")
public class ThinController {
@RequestMapping(path = "/hello", method = RequestMethod.GET)
public String hello(){
return "success...";
}
}
Upvotes: 3