I have two types of controllers in my spring application.
- View controllers that forward to views to generate HTML
- API controllers that return JSON directly from the controllers
Both the API and View controllers are part of the same spring dispatcher servlet.
The documentation implies that @ControllerAdvice will be applied to every controller associated with a Dispatcher Servlet. With advice as part of the name I expected to be able to specify the pointcut and or join points that the advice applies to, but can't find out how that can be.
For example in my scenario I want a @ControllerAdvice for my View Controllers and separate @ControllerAdvice for my API controllers.
It would be great to provide a way to configure which controllers @ControllerAdvice will apply to.