juniorSpring
What is @ControllerAdvice?
Updated May 17, 2026
Short answer
It handles global exceptions across controllers.
Deep explanation
It allows centralized exception handling using @ExceptionHandler methods, improving separation of concerns.
Real-world example
Central error handling in REST APIs.
Common mistakes
- Writing exception handling in every controller.
Follow-up questions
- Difference between @ControllerAdvice and @RestControllerAdvice?
- Can it handle validation errors?