0

I am using Spring MVC 3.2.4. I want to extend an existing annotated base controller to override some existing methods. Here is what I want to do,

/**Base Controller**/
 @controller
 public class BaseController {

  @RequestMapping(value="/process")
  public String doStuff(){
   //do something
  }
 }

/**Child Controller**/
@controller
public class ChildController extends BaseController {

  @RequestMapping(value="/specicalProcess")
  public String doStuff(){
  //do special thing
  super.doStuff();
 }
}

But I got "ambiguous mapping found" error. I wonder if Spring MVC doesn't support overriding a super method with @RequestMapping annotation and how I can extend annotated base controller. In my case, I don't want to remove all annotation from base controller to make it work. Any thoughts? Many thanks in advance.

felix tse
  • 21
  • 2
  • Can't you simply rename the method in your `ChildController`? – sp00m Mar 14 '14 at 10:15
  • Or make your BaseController no an `@Controller`. The problem is, once you extend it, you now how two classes defining the exact same methods with the exact same `@RequestMapping`s. – CodeChimp Mar 14 '14 at 11:37
  • In my case, the requestmapping of child controller is different than the one of base controller. So, does it mean that Requestmapping annotation cannot be overridden in Spring MVC? does it mean using Spring MVC annotation programming would not be fully complied with OOP's polymorphism? @sp00m – felix tse Mar 14 '14 at 13:21

0 Answers0