Error & Exception Handling
Error & Exception Handling
• Error and Exception are the unwanted events that occurs during the excecution of our
program
• In Spring WEB-MVC, we can handle the error or exception by 3 ways :-
1. By web.xml file
2. By pre-defined class (SimpleMappingExceptionResolver)
3. By annotations (@ExceptionHandler)
The above sended requests will go to the controller and the controller will open
the corresponding page
2. Handling exception using pre-defined classes
3. @ExceptionHandler :-
• It is used to define a method that handles exceptions which are thrown by the other
methods in the controller
• It provides a way to centralize the exception handling and present a consistent response
to the client in case of errors