Explain me how to handle exceptions in Spring MVC Framework?
Submitted by: MuhammadSpring 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.
Submitted by: Muhammad
☛ 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.
Submitted by: Muhammad
Read Online Sr.Java Web Developer Job Interview Questions And Answers
Top Sr.Java Web Developer Questions
☺ | Tell me how to delete a Cookie in a JSP? |
☺ | Tell us what kind of HTTP request does the <a href="url">text</a> generate? |
☺ | Tell me how does cookies work in Servlets? |
☺ | Tell me what are the reasons for a page not found error and how will you sort it out? |
☺ | Tell me what are the steps to connect to a database in java? |
Top Java Programming Language Categories
☺ | Core Java Interview Questions. |
☺ | Hibernate Interview Questions. |
☺ | Advanced Java Interview Questions. |
☺ | IBM WebSphere Interview Questions. |
☺ | Spring Framework Interview Questions. |