Interview questions
Question 89 of 254
FreeWhat is @ControllerAdvice / @RestControllerAdvice, and what is it used for?
Exception Handling & Validation
@ControllerAdvice (and its REST-focused variant @RestControllerAdvice, which adds @ResponseBody) marks a class as a global, cross-cutting handler applied across all (or a filtered subset of) @Controller classes — most commonly used to centralize exception handling via @ExceptionHandler methods, so individual controllers don't each need their own duplicated try/catch or error-mapping logic.
Intermediate5 min

