I have two types of controllers in my spring application.
Both the API and View controllers are part of the same spring dispatcher servlet. Spring 3.2 introduced the @ControllerAdvice
annotation to allow for a global location to handle exception.
The documentation implies that @ControllerAdvice
will be applied to every controller associated with a Dispatcher Servlet.
Is there a way to configure which controllers @ControllerAdvice
will apply to?
For example in my scenario I want a @ControllerAdvice
for my View Controllers and separate @ControllerAdvice
for my API controllers.
For people that will still find this question:
As from Spring 4 ControlerAdvice's can be limited to Controler's with the specified annotations. Take a look at:
http://blog.codeleak.pl/2013/11/controlleradvice-improvements-in-spring.html
(second half of this article) for more details.