Good, therefore, if I understand correctly, you want inheritance to continue to play a role on the stack when the request is processed by the controller. You can extend any class in annotated POJO @RequestMapping, but you will need to define an @override method to annotate it. All you do basically is call super with the arguments in the override method. If you extend the annotated class and both are declared as Controller, then you will get an exception, since the route will be defined more than once.
he will look like
public class Pojo{ public String someBaseMethod(){ return ""; } } @Controller public class ChildController extends Pojo { @Override @RequestMapping("/do_it") public String someBaseMethod() { return super.someBaseMethod(); } }
A good case can be made to use composition over inheritance. I even suggest using a filtering mechanism if it can be used to perform general operations. AOP can also be a good tool.
source share