in Spring by
Q:

How to handle exceptions in Spring MVC Framework?

1 Answer

0 votes
by

Spring MVC Framework provides the following ways to help us achieving robust exception handling.

Controller Based – We can define exception handler methods in our controller classes. All we need is to annotate these methods with @ExceptionHandler annotation.

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 – For generic exceptions, most of the times we serve static pages. 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.

For a complete example, please read Spring Exception Handling Example.

Click here to read more about Loan/Mortgage
Click here to read more about Insurance

Related questions

0 votes
asked Jul 28, 2020 in Spring by sharadyadav1986
0 votes
asked Jul 26, 2020 in Spring by SakshiSharma
0 votes
asked Feb 9 in JAVA by SakshiSharma
0 votes
asked Jul 28, 2020 in Spring by sharadyadav1986
0 votes
asked May 24, 2019 in JAVA by rajeshsharma
...