org.springframework.web.servlet.HandlerExceptionResolver
interface, resolving standard Spring MVC exceptions and translating them to corresponding
HTTP status codes.
This exception resolver is enabled by default in the common Spring
org..
| Exception | HTTP Status Code |
|---|---|
HttpRequestMethodNotSupportedException |
405 (SC_METHOD_NOT_ALLOWED) |
HttpMediaTypeNotSupportedException |
415 (SC_UNSUPPORTED_MEDIA_TYPE) |
HttpMediaTypeNotAcceptableException |
406 (SC_NOT_ACCEPTABLE) |
MissingPathVariableException |
500 (SC_INTERNAL_SERVER_ERROR) |
MissingServletRequestParameterException |
400 (SC_BAD_REQUEST) |
MissingServletRequestPartException |
400 (SC_BAD_REQUEST) |
ServletRequestBindingException |
400 (SC_BAD_REQUEST) |
ConversionNotSupportedException |
500 (SC_INTERNAL_SERVER_ERROR) |
TypeMismatchException |
400 (SC_BAD_REQUEST) |
HttpMessageNotReadableException |
400 (SC_BAD_REQUEST) |
HttpMessageNotWritableException |
500 (SC_INTERNAL_SERVER_ERROR) |
MethodArgumentNotValidException |
400 (SC_BAD_REQUEST) |
400 (SC_BAD_REQUEST) |
|
NoHandlerFoundException |
404 (SC_NOT_FOUND) |
NoResourceFoundException |
404 (SC_NOT_FOUND) |
AsyncRequestTimeoutException |
503 (SC_SERVICE_UNAVAILABLE) |
500 (SC_INTERNAL_SERVER_ERROR) |
org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler
| Modifier and Type | Field and Description |
|---|---|
| public static final String | PAGE_NOT_FOUND_LOG_CATEGORY
Log category to use when no mapped handler is found for a request. |
| protected static final Log | pageNotFoundLogger
Additional logger to use when no mapped handler is found for a request. |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| protected ModelAndView | doResolveException(HttpServletRequest
current HTTP request request, HttpServletResponse current HTTP response response, Object the executed handler, or handler, Exception null if none chosen at the time
of the exception (for example, if multipart resolution failed)the exception that got thrown during handler execution ex)Implements abstract org. Actually resolve the given exception that got thrown during handler execution,
returning a |
| protected ModelAndView | Returns: an emptyModelAndView indicating the exception was handled, or
null indicating the exception should be handled in handleErrorResponsethe ex, HttpServletRequest AsyncRequestTimeoutException to be handledcurrent HTTP request request, HttpServletResponse current HTTP response response, Object the executed handler, or handler)null if none chosen
at the time of the exception (for example, if multipart resolution failed)Handle the case where an async request timed out. |
| protected ModelAndView | Returns: an emptyModelAndView indicating the exception was handledcurrent HTTP request request, HttpServletResponse current HTTP response response, Object the executed handler handler)
Deprecated
for removal since 6.0. as of 6.0 since
org.
now raises the MethodArgumentNotValidException subclass instead.
Handle the case where an @ModelAttribute method
argument has binding or validation errors and is not followed by another
method argument of type |
| protected ModelAndView | Returns: an emptyModelAndView indicating the exception was handledthe ConversionNotSupportedException to be handled ex, HttpServletRequest current HTTP request request, HttpServletResponse current HTTP response response, Object the executed handler handler)Handle the case when a |
| protected ModelAndView | Returns: an emptyModelAndView indicating the exception was handledthe exception to be handled errorResponse, HttpServletRequest current HTTP request request, HttpServletResponse current HTTP response response, Object the executed handler handler)Handle an |
| protected ModelAndView | Returns: an emptyModelAndView indicating the exception was handled, or
null indicating the exception should be handled in handleErrorResponsethe exception to be handled ex, HttpServletRequest current HTTP request request, HttpServletResponse current HTTP response response, Object the executed handler handler)Handle the case where method validation for a controller method failed. |
| protected ModelAndView | Returns: an emptyModelAndView indicating the exception was handled, or
null indicating the exception should be handled in handleErrorResponsethe HttpMediaTypeNotAcceptableException to be handled ex, HttpServletRequest current HTTP request request, HttpServletResponse current HTTP response response, Object the executed handler handler)Handle the case where no
message converters
were found that were acceptable for the client (expressed via the |
| protected ModelAndView | Returns: an emptyModelAndView indicating the exception was handled, or
null indicating the exception should be handled in handleErrorResponsethe HttpMediaTypeNotSupportedException to be handled ex, HttpServletRequest current HTTP request request, HttpServletResponse current HTTP response response, Object the executed handler handler)Handle the case where no message converters were found for PUT or POSTed content. |
| protected ModelAndView | Returns: an emptyModelAndView indicating the exception was handledthe HttpMessageNotReadableException to be handled ex, HttpServletRequest current HTTP request request, HttpServletResponse current HTTP response response, Object the executed handler handler)Handle the case where a message converter cannot read from an HTTP request. |
| protected ModelAndView | Returns: an emptyModelAndView indicating the exception was handledthe HttpMessageNotWritableException to be handled ex, HttpServletRequest current HTTP request request, HttpServletResponse current HTTP response response, Object the executed handler handler)Handle the case where a message converter cannot write to an HTTP response. |
| protected ModelAndView | Returns: an emptyModelAndView indicating the exception was handled, or
null indicating the exception should be handled in handleErrorResponsethe HttpRequestMethodNotSupportedException to be handled ex, HttpServletRequest current HTTP request request, HttpServletResponse current HTTP response response, Object the executed handler, or handler)null if none chosen
at the time of the exception (for example, if multipart resolution failed)Handle the case where no handler was found for the HTTP method. |
| protected ModelAndView | Returns: an emptyModelAndView indicating the exception was handled, or
null indicating the exception should be handled in handleErrorResponsecurrent HTTP request request, HttpServletResponse current HTTP response response, Object the executed handler handler)Handle the case where an argument annotated with |
| protected ModelAndView | Returns: an emptyModelAndView indicating the exception was handledthe exception to be handled ex, HttpServletRequest current HTTP request request, HttpServletResponse current HTTP response response, Object the executed handler handler)Handle the case where method validation failed on a component that is not a web controller, e.g. on some underlying service. |
| protected ModelAndView | Returns: an emptyModelAndView indicating the exception was handled, or
null indicating the exception should be handled in handleErrorResponsethe MissingPathVariableException to be handled ex, HttpServletRequest current HTTP request request, HttpServletResponse current HTTP response response, Object the executed handler handler)Handle the case when a declared path variable does not match any extracted URI variable. |
| protected ModelAndView | Returns: an emptyModelAndView indicating the exception was handled, or
null indicating the exception should be handled in handleErrorResponsethe MissingServletRequestParameterException to be handled ex, HttpServletRequest current HTTP request request, HttpServletResponse current HTTP response response, Object the executed handler handler)Handle the case when a required parameter is missing. |
| protected ModelAndView | Returns: an emptyModelAndView indicating the exception was handled, or
null indicating the exception should be handled in handleErrorResponsecurrent HTTP request request, HttpServletResponse current HTTP response response, Object the executed handler handler)Handle the case where an @RequestPart, a |
| protected ModelAndView | Returns: an emptyModelAndView indicating the exception was handled, or
null indicating the exception should be handled in handleErrorResponsethe NoHandlerFoundException to be handled ex, HttpServletRequest current HTTP request request, HttpServletResponse current HTTP response response, Object the executed handler, or handler)null if none chosen
at the time of the exception (for example, if multipart resolution failed)Handle the case where no handler was found during the dispatch. |
| protected ModelAndView | Returns: an emptyModelAndView indicating the exception was handled, or
null indicating the exception should be handled in handleErrorResponsethe ex, HttpServletRequest NoResourceFoundException to be handledcurrent HTTP request request, HttpServletResponse current HTTP response response, Object the resource handler handler)Handle the case where no static resource was found. |
| protected ModelAndView | Returns: an emptyModelAndView indicating the exception was handled, or
null indicating the exception should be handled in handleErrorResponsethe exception to be handled ex, HttpServletRequest current HTTP request request, HttpServletResponse current HTTP response response, Object the executed handler handler)Handle the case when an unrecoverable binding exception occurs - e.g. required header, required cookie. |
| protected ModelAndView | Returns: an emptyModelAndView indicating the exception was handledthe TypeMismatchException to be handled ex, HttpServletRequest current HTTP request request, HttpServletResponse current HTTP response response, Object the executed handler handler)Handle the case when a |
| protected void | logException(Exception
the exception that got thrown during handler execution ex, HttpServletRequest current HTTP request (useful for obtaining metadata) request)Overrides org. Log the given exception at warn level, provided that warn logging has been
activated through the |
| protected void | sendServerError(Exception ex, HttpServletRequest request, HttpServletResponse response)
Invoked to send a server error. |