Spring / Spring MVC Interview questions
How do I handle exceptions in Spring MVC Framework?
Spring MVC Framework provides the following methods to achieve robust exception handling.
Controller Based- define the exception handler methods in controller classes and annotate these methods with
Global Exception Handler- Exception Handling is a cross-cutting concern and Spring provides
@ControllerAdvice annotation that we can use with any class to define our global exception handler.
HandlerExceptionResolver implementation- Spring Framework provides
HandlerExceptionResolver interface that we can implement to create global exception handler. The reason behind this additional way to define global exception handler is that Spring framework also provides default implementation classes that we can define in our spring bean configuration file to get spring framework exception handling benefits.
More Related questions...