The @ControllerAdvice annotation allows us to write global code applicable to a wide range of controllers.
My Question is:
@ControllerAdvice is applicable to only controller level and Spring AOP is based on pointcut.
Other than this, what are the differences between them and when to use @ControllerAdviceand Spring AOP?
I was trying to implement something like shown in this example link.
Link Here
@ControllerAdvice is one of the AOP features Spring offers. The main difference in use case is that @ControllerAdvice is wired up by the Spring MVC infrastructure and uses (and provides) Web-specific features. Use it if you're writing advice that specifically applies to Web requests, such as error handling (e.g., translating exceptions into an enterprise-standard JSON error format). Otherwise, aspects are the approach.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With