Edit: please read the question curefully, I don't need answers that repeat what I wrote.
Looking aroung the web I found quite a confusion about this subject.
What I'm looking for is a nice way to extend the value of a Controller's RequestMapping annotation.
Such as:
@Controller
@RequestMapping("/api")
public class ApiController {}
@Controller
@RequestMapping("/dashboard")
public class DashboardApiController extends ApiController {}
The result should be ("/api/dashboard").
This approach apparently simply override the RequestMapping value.
A working approach may be to not put a RequestMapping annotation on the derived class.
@Controller
public class DashboardApiController extends ApiController
{
@GetMapping("/dashboard")
public String dashboardHome() {
return "dashboard";
}
... other methods prefixed with "/dashboard"
}
Is this the only feasible approach? I don't really like it.
This is not the elegant solution you're looking for, but here's a functional solution I used.
@Controller
@RequestMapping(BASE_URI)
public class ApiController {
protected final static String BASE_URI = "/api";
}
@Controller
@RequestMapping(ApiController.BASE_URI + "/dashboard")
public class DashboardApiController extends ApiController {}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With