I am working on a small project and have some existing code that I want to keep clean from my changes, and therefore I need to extend the annotated controller, but this does not work:
package a; @controller public class BaseController { // Autowired fields protected x toExtend() { // do stuff } @RequestMapping(value = "/start") protected ModelAndView setupForm(...) { toExtend(); // more stuff } } package b; @controller public class NewController extends BaseController { // Autowired fields @Override protected x toExtend() { super.toExtend(); //new stuff } }
Package a and b are scanned for controllers, and I cannot change this. I really did not expect this to work, because @RequestMapping (value = "/ start") is redundant in both controllers. And I get an exception because of this.
So my question is, is it possible to extend the annotation-controlled controller at all without changing the BaseController?
source share