• For global exception handling use @ControllerAdvice annotation along with @ExceptionHandler method annotation for any class

Example: Global Exception Handling using @ControllerAdvice

Global Exception Handling: HandlerExceptionResolver

  • Create a custom global error handler by implementing HandlerExceptionResolver interface
  • It enables mapping exceptions to a view name

Example: MappingExceptionResolver – with Java Configuration

Example: MappingExceptinResolver – with XML Configuration

Sample Custom Error Page