The DispatcherServlet
will catch any unhandled exception thrown while executing
handlers or handler interceptors and delegate them to
HandlerExceptionResolvers
to map the unhandled exception to a ModelAndView
. Spring throws different
unchecked exceptions when the DispatcherServlet
is unable to resolve a request to
a controller or fails to bind the request to it, for example because no matching type
converter is defined. The default HandlerExceptionResolver
simply maps these exception types
to HTTP status codes such as 404 (NOT FOUND) or 400 (BAD
REQUEST). A list of the default status code mappings is included in the
Spring
documentation. For consistent error pages, it is recommended to define a custom
exception resolver and map unhandled exceptions to
HttpError
models to share error views with explicit exception handling.