Spring MVC @RequestMapping Inheritance

The following basically becomes /tweeter/updateStatus and not /user/tweeter/updateStatus

public abstract class TwitterController extends AbstractTwitterController {

    @RequestMapping(value = "/updateStatus")    
    public String updateStatus() {
        ....
    }
}

That’s the expected behavior since you’ve overriden the original @RequestMapping you’ve declared in the AbstractController and AbstractUserController.

In fact when you declared that AbstractUserController it also overriden the @RequestMapping for AbstractController. It just gives you the illusion that the / from the AbstractController has been inherited.

“Is there a setting I can enable that will scan the superclasses for @RequestMapping annotations and construct the correct path?” Not that I know of.

Leave a Comment