With Spring MVC, I know how you set the RequestMapping
in every controller and method/action.
But what if I wanted this to be configurable, so for example I
Also another solution might be to create a custom annotation that holds the already defined path on the @RequestMapping
and also the new one to apply, let's say @ApiRestController
.
Then, before the Spring context loads, the @Controller
classes can be changed to have their annotation values changed at runtime by the new one (with the desired path). By doing this, Spring will load the enhanced request mapping and not the default one.
Created a small project to exemplify this for someone that needs this in the future https://gitlab.com/jdiasamaro/spring-api-rest-controllers.
Hope it helps. Cheers.