Class DefaultHandlerExceptionResolver
- All Implemented Interfaces:
- Ordered,- HandlerExceptionResolver
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
 DispatcherServlet.
 
Supported Exceptions
| 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) | 
| 500 (SC_INTERNAL_SERVER_ERROR) | |
| 400 (SC_BAD_REQUEST) | |
| NoHandlerFoundException | 404 (SC_NOT_FOUND) | 
| NoResourceFoundException | 404 (SC_NOT_FOUND) | 
| AsyncRequestTimeoutException | 503 (SC_SERVICE_UNAVAILABLE) | 
| AsyncRequestNotUsableException | Not applicable | 
- Since:
- 3.0
- Author:
- Arjen Poutsma, Rossen Stoyanchev, Juergen Hoeller
- See Also:
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final StringLog category to use when no mapped handler is found for a request.protected static final org.apache.commons.logging.LogAdditional logger to use when no mapped handler is found for a request.Fields inherited from class org.springframework.web.servlet.handler.AbstractHandlerExceptionResolverloggerFields inherited from interface org.springframework.core.OrderedHIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionprotected @Nullable ModelAndViewdoResolveException(HttpServletRequest request, HttpServletResponse response, @Nullable Object handler, Exception ex) Actually resolve the given exception that got thrown during handler execution, returning aModelAndViewthat represents a specific error page if appropriate.protected ModelAndViewhandleAsyncRequestNotUsableException(AsyncRequestNotUsableException ex, HttpServletRequest request, HttpServletResponse response, @Nullable Object handler) Handle the case of an I/O failure from the ServletOutputStream.protected @Nullable ModelAndViewhandleAsyncRequestTimeoutException(AsyncRequestTimeoutException ex, HttpServletRequest request, HttpServletResponse response, @Nullable Object handler) Handle the case where an async request timed out.protected ModelAndViewhandleConversionNotSupported(ConversionNotSupportedException ex, HttpServletRequest request, HttpServletResponse response, @Nullable Object handler) Handle the case when aWebDataBinderconversion cannot occur.protected ModelAndViewhandleDisconnectedClientException(Exception ex, HttpServletRequest request, HttpServletResponse response, @Nullable Object handler) Handle an Exception that indicates the client has gone away.protected ModelAndViewhandleErrorResponse(ErrorResponse errorResponse, HttpServletRequest request, HttpServletResponse response, @Nullable Object handler) Handle anErrorResponseexception.protected @Nullable ModelAndViewhandleHandlerMethodValidationException(HandlerMethodValidationException ex, HttpServletRequest request, HttpServletResponse response, @Nullable Object handler) Handle the case where method validation for a controller method failed.protected @Nullable ModelAndViewhandleHttpMediaTypeNotAcceptable(HttpMediaTypeNotAcceptableException ex, HttpServletRequest request, HttpServletResponse response, @Nullable Object handler) Handle the case where no message converters were found that were acceptable for the client (expressed via theAcceptheader).protected @Nullable ModelAndViewhandleHttpMediaTypeNotSupported(HttpMediaTypeNotSupportedException ex, HttpServletRequest request, HttpServletResponse response, @Nullable Object handler) Handle the case where no message converters were found for PUT or POSTed content.protected ModelAndViewhandleHttpMessageNotReadable(HttpMessageNotReadableException ex, HttpServletRequest request, HttpServletResponse response, @Nullable Object handler) Handle the case where a message converter cannot read from an HTTP request.protected ModelAndViewhandleHttpMessageNotWritable(HttpMessageNotWritableException ex, HttpServletRequest request, HttpServletResponse response, @Nullable Object handler) Handle the case where a message converter cannot write to an HTTP response.protected @Nullable ModelAndViewhandleHttpRequestMethodNotSupported(HttpRequestMethodNotSupportedException ex, HttpServletRequest request, HttpServletResponse response, @Nullable Object handler) Handle the case where no handler was found for the HTTP method.protected @Nullable ModelAndViewhandleMethodArgumentNotValidException(MethodArgumentNotValidException ex, HttpServletRequest request, HttpServletResponse response, @Nullable Object handler) Handle the case where an argument annotated with@Validsuch as anRequestBodyorRequestPartargument fails validation.protected ModelAndViewhandleMethodValidationException(MethodValidationException ex, HttpServletRequest request, HttpServletResponse response, @Nullable Object handler) Handle the case where method validation failed on a component that is not a web controller, for example, on some underlying service.protected @Nullable ModelAndViewhandleMissingPathVariable(MissingPathVariableException ex, HttpServletRequest request, HttpServletResponse response, @Nullable Object handler) Handle the case when a declared path variable does not match any extracted URI variable.protected @Nullable ModelAndViewhandleMissingServletRequestParameter(MissingServletRequestParameterException ex, HttpServletRequest request, HttpServletResponse response, @Nullable Object handler) Handle the case when a required parameter is missing.protected @Nullable ModelAndViewhandleMissingServletRequestPartException(MissingServletRequestPartException ex, HttpServletRequest request, HttpServletResponse response, @Nullable Object handler) Handle the case where an @RequestPart, aMultipartFile, or ajakarta.servlet.http.Partargument is required but is missing.protected @Nullable ModelAndViewhandleNoHandlerFoundException(NoHandlerFoundException ex, HttpServletRequest request, HttpServletResponse response, @Nullable Object handler) Handle the case where no handler was found during the dispatch.protected @Nullable ModelAndViewhandleNoResourceFoundException(NoResourceFoundException ex, HttpServletRequest request, HttpServletResponse response, @Nullable Object handler) Handle the case where no static resource was found.protected @Nullable ModelAndViewhandleServletRequestBindingException(ServletRequestBindingException ex, HttpServletRequest request, HttpServletResponse response, @Nullable Object handler) Handle the case when an unrecoverable binding exception occurs - for example, required header, required cookie.protected ModelAndViewhandleTypeMismatch(TypeMismatchException ex, HttpServletRequest request, HttpServletResponse response, @Nullable Object handler) Handle the case when aWebDataBinderconversion error occurs.protected voidlogException(Exception ex, HttpServletRequest request) Log the given exception at warn level, provided that warn logging has been activated through the"warnLogCategory"property.protected voidsendServerError(Exception ex, HttpServletRequest request, HttpServletResponse response) Invoked to send a server error.Methods inherited from class org.springframework.web.servlet.handler.AbstractHandlerExceptionResolveraddMappedHandlerClass, buildLogMessage, getMappedHandlerClasses, getOrder, hasHandlerMappings, prepareResponse, preventCaching, resolveException, setMappedHandlerClasses, setMappedHandlerPredicate, setMappedHandlers, setOrder, setPreventResponseCaching, setWarnLogCategory, shouldApplyTo
- 
Field Details- 
PAGE_NOT_FOUND_LOG_CATEGORYLog category to use when no mapped handler is found for a request.- See Also:
 
- 
pageNotFoundLoggerprotected static final org.apache.commons.logging.Log pageNotFoundLoggerAdditional logger to use when no mapped handler is found for a request.- See Also:
 
 
- 
- 
Constructor Details- 
DefaultHandlerExceptionResolverpublic DefaultHandlerExceptionResolver()Sets the order toOrdered.LOWEST_PRECEDENCE.
 
- 
- 
Method Details- 
doResolveExceptionprotected @Nullable ModelAndView doResolveException(HttpServletRequest request, HttpServletResponse response, @Nullable Object handler, Exception ex) Description copied from class:AbstractHandlerExceptionResolverActually resolve the given exception that got thrown during handler execution, returning aModelAndViewthat represents a specific error page if appropriate.May be overridden in subclasses, in order to apply specific exception checks. Note that this template method will be invoked after checking whether this resolver applies ("mappedHandlers" etc), so an implementation may simply proceed with its actual exception handling. - Specified by:
- doResolveExceptionin class- AbstractHandlerExceptionResolver
- Parameters:
- request- current HTTP request
- response- current HTTP response
- handler- the executed handler, or- nullif none chosen at the time of the exception (for example, if multipart resolution failed)
- ex- the exception that got thrown during handler execution
- Returns:
- a corresponding ModelAndViewto forward to, ornullfor default processing in the resolution chain
 
- 
handleHttpRequestMethodNotSupportedprotected @Nullable ModelAndView handleHttpRequestMethodNotSupported(HttpRequestMethodNotSupportedException ex, HttpServletRequest request, HttpServletResponse response, @Nullable Object handler) throws IOException Handle the case where no handler was found for the HTTP method.The default implementation returns nullin which case the exception is handled inhandleErrorResponse(org.springframework.web.ErrorResponse, jakarta.servlet.http.HttpServletRequest, jakarta.servlet.http.HttpServletResponse, java.lang.Object).- Parameters:
- ex- the HttpRequestMethodNotSupportedException to be handled
- request- current HTTP request
- response- current HTTP response
- handler- the executed handler, or- nullif none chosen at the time of the exception (for example, if multipart resolution failed)
- Returns:
- an empty ModelAndViewindicating the exception was handled, ornullindicating the exception should be handled inhandleErrorResponse(org.springframework.web.ErrorResponse, jakarta.servlet.http.HttpServletRequest, jakarta.servlet.http.HttpServletResponse, java.lang.Object)
- Throws:
- IOException- potentially thrown from- HttpServletResponse.sendError(int, java.lang.String)
 
- 
handleHttpMediaTypeNotSupportedprotected @Nullable ModelAndView handleHttpMediaTypeNotSupported(HttpMediaTypeNotSupportedException ex, HttpServletRequest request, HttpServletResponse response, @Nullable Object handler) throws IOException Handle the case where no message converters were found for PUT or POSTed content.The default implementation returns nullin which case the exception is handled inhandleErrorResponse(org.springframework.web.ErrorResponse, jakarta.servlet.http.HttpServletRequest, jakarta.servlet.http.HttpServletResponse, java.lang.Object).- Parameters:
- ex- the HttpMediaTypeNotSupportedException to be handled
- request- current HTTP request
- response- current HTTP response
- handler- the executed handler
- Returns:
- an empty ModelAndViewindicating the exception was handled, ornullindicating the exception should be handled inhandleErrorResponse(org.springframework.web.ErrorResponse, jakarta.servlet.http.HttpServletRequest, jakarta.servlet.http.HttpServletResponse, java.lang.Object)
- Throws:
- IOException- potentially thrown from- HttpServletResponse.sendError(int, java.lang.String)
 
- 
handleHttpMediaTypeNotAcceptableprotected @Nullable ModelAndView handleHttpMediaTypeNotAcceptable(HttpMediaTypeNotAcceptableException ex, HttpServletRequest request, HttpServletResponse response, @Nullable Object handler) throws IOException Handle the case where no message converters were found that were acceptable for the client (expressed via theAcceptheader).The default implementation returns nullin which case the exception is handled inhandleErrorResponse(org.springframework.web.ErrorResponse, jakarta.servlet.http.HttpServletRequest, jakarta.servlet.http.HttpServletResponse, java.lang.Object).- Parameters:
- ex- the HttpMediaTypeNotAcceptableException to be handled
- request- current HTTP request
- response- current HTTP response
- handler- the executed handler
- Returns:
- an empty ModelAndViewindicating the exception was handled, ornullindicating the exception should be handled inhandleErrorResponse(org.springframework.web.ErrorResponse, jakarta.servlet.http.HttpServletRequest, jakarta.servlet.http.HttpServletResponse, java.lang.Object)
- Throws:
- IOException- potentially thrown from- HttpServletResponse.sendError(int, java.lang.String)
 
- 
handleMissingPathVariableprotected @Nullable ModelAndView handleMissingPathVariable(MissingPathVariableException ex, HttpServletRequest request, HttpServletResponse response, @Nullable Object handler) throws IOException Handle the case when a declared path variable does not match any extracted URI variable.The default implementation returns nullin which case the exception is handled inhandleErrorResponse(org.springframework.web.ErrorResponse, jakarta.servlet.http.HttpServletRequest, jakarta.servlet.http.HttpServletResponse, java.lang.Object).- Parameters:
- ex- the MissingPathVariableException to be handled
- request- current HTTP request
- response- current HTTP response
- handler- the executed handler
- Returns:
- an empty ModelAndViewindicating the exception was handled, ornullindicating the exception should be handled inhandleErrorResponse(org.springframework.web.ErrorResponse, jakarta.servlet.http.HttpServletRequest, jakarta.servlet.http.HttpServletResponse, java.lang.Object)
- Throws:
- IOException- potentially thrown from- HttpServletResponse.sendError(int, java.lang.String)
- Since:
- 4.2
 
- 
handleMissingServletRequestParameterprotected @Nullable ModelAndView handleMissingServletRequestParameter(MissingServletRequestParameterException ex, HttpServletRequest request, HttpServletResponse response, @Nullable Object handler) throws IOException Handle the case when a required parameter is missing.The default implementation returns nullin which case the exception is handled inhandleErrorResponse(org.springframework.web.ErrorResponse, jakarta.servlet.http.HttpServletRequest, jakarta.servlet.http.HttpServletResponse, java.lang.Object).- Parameters:
- ex- the MissingServletRequestParameterException to be handled
- request- current HTTP request
- response- current HTTP response
- handler- the executed handler
- Returns:
- an empty ModelAndViewindicating the exception was handled, ornullindicating the exception should be handled inhandleErrorResponse(org.springframework.web.ErrorResponse, jakarta.servlet.http.HttpServletRequest, jakarta.servlet.http.HttpServletResponse, java.lang.Object)
- Throws:
- IOException- potentially thrown from- HttpServletResponse.sendError(int, java.lang.String)
 
- 
handleMissingServletRequestPartExceptionprotected @Nullable ModelAndView handleMissingServletRequestPartException(MissingServletRequestPartException ex, HttpServletRequest request, HttpServletResponse response, @Nullable Object handler) throws IOException Handle the case where an @RequestPart, aMultipartFile, or ajakarta.servlet.http.Partargument is required but is missing.By default, an HTTP 400 error is sent back to the client. - Parameters:
- request- current HTTP request
- response- current HTTP response
- handler- the executed handler
- Returns:
- an empty ModelAndViewindicating the exception was handled, ornullindicating the exception should be handled inhandleErrorResponse(org.springframework.web.ErrorResponse, jakarta.servlet.http.HttpServletRequest, jakarta.servlet.http.HttpServletResponse, java.lang.Object)
- Throws:
- IOException- potentially thrown from- HttpServletResponse.sendError(int, java.lang.String)
 
- 
handleServletRequestBindingExceptionprotected @Nullable ModelAndView handleServletRequestBindingException(ServletRequestBindingException ex, HttpServletRequest request, HttpServletResponse response, @Nullable Object handler) throws IOException Handle the case when an unrecoverable binding exception occurs - for example, required header, required cookie.The default implementation returns nullin which case the exception is handled inhandleErrorResponse(org.springframework.web.ErrorResponse, jakarta.servlet.http.HttpServletRequest, jakarta.servlet.http.HttpServletResponse, java.lang.Object).- Parameters:
- ex- the exception to be handled
- request- current HTTP request
- response- current HTTP response
- handler- the executed handler
- Returns:
- an empty ModelAndViewindicating the exception was handled, ornullindicating the exception should be handled inhandleErrorResponse(org.springframework.web.ErrorResponse, jakarta.servlet.http.HttpServletRequest, jakarta.servlet.http.HttpServletResponse, java.lang.Object)
- Throws:
- IOException- potentially thrown from- HttpServletResponse.sendError(int, java.lang.String)
 
- 
handleMethodArgumentNotValidExceptionprotected @Nullable ModelAndView handleMethodArgumentNotValidException(MethodArgumentNotValidException ex, HttpServletRequest request, HttpServletResponse response, @Nullable Object handler) throws IOException Handle the case where an argument annotated with@Validsuch as anRequestBodyorRequestPartargument fails validation.The default implementation returns nullin which case the exception is handled inhandleErrorResponse(org.springframework.web.ErrorResponse, jakarta.servlet.http.HttpServletRequest, jakarta.servlet.http.HttpServletResponse, java.lang.Object).- Parameters:
- request- current HTTP request
- response- current HTTP response
- handler- the executed handler
- Returns:
- an empty ModelAndViewindicating the exception was handled, ornullindicating the exception should be handled inhandleErrorResponse(org.springframework.web.ErrorResponse, jakarta.servlet.http.HttpServletRequest, jakarta.servlet.http.HttpServletResponse, java.lang.Object)
- Throws:
- IOException- potentially thrown from- HttpServletResponse.sendError(int, java.lang.String)
 
- 
handleHandlerMethodValidationExceptionprotected @Nullable ModelAndView handleHandlerMethodValidationException(HandlerMethodValidationException ex, HttpServletRequest request, HttpServletResponse response, @Nullable Object handler) throws IOException Handle the case where method validation for a controller method failed.The default implementation returns nullin which case the exception is handled inhandleErrorResponse(org.springframework.web.ErrorResponse, jakarta.servlet.http.HttpServletRequest, jakarta.servlet.http.HttpServletResponse, java.lang.Object).- Parameters:
- ex- the exception to be handled
- request- current HTTP request
- response- current HTTP response
- handler- the executed handler
- Returns:
- an empty ModelAndViewindicating the exception was handled, ornullindicating the exception should be handled inhandleErrorResponse(org.springframework.web.ErrorResponse, jakarta.servlet.http.HttpServletRequest, jakarta.servlet.http.HttpServletResponse, java.lang.Object)
- Throws:
- IOException- potentially thrown from- HttpServletResponse.sendError(int, java.lang.String)
- Since:
- 6.1
 
- 
handleNoHandlerFoundExceptionprotected @Nullable ModelAndView handleNoHandlerFoundException(NoHandlerFoundException ex, HttpServletRequest request, HttpServletResponse response, @Nullable Object handler) throws IOException Handle the case where no handler was found during the dispatch.The default implementation returns nullin which case the exception is handled inhandleErrorResponse(org.springframework.web.ErrorResponse, jakarta.servlet.http.HttpServletRequest, jakarta.servlet.http.HttpServletResponse, java.lang.Object).- Parameters:
- ex- the NoHandlerFoundException to be handled
- request- current HTTP request
- response- current HTTP response
- handler- the executed handler, or- nullif none chosen at the time of the exception (for example, if multipart resolution failed)
- Returns:
- an empty ModelAndViewindicating the exception was handled, ornullindicating the exception should be handled inhandleErrorResponse(org.springframework.web.ErrorResponse, jakarta.servlet.http.HttpServletRequest, jakarta.servlet.http.HttpServletResponse, java.lang.Object)
- Throws:
- IOException- potentially thrown from- HttpServletResponse.sendError(int, java.lang.String)
- Since:
- 4.0
 
- 
handleNoResourceFoundExceptionprotected @Nullable ModelAndView handleNoResourceFoundException(NoResourceFoundException ex, HttpServletRequest request, HttpServletResponse response, @Nullable Object handler) throws IOException Handle the case where no static resource was found.The default implementation returns nullin which case the exception is handled inhandleErrorResponse(org.springframework.web.ErrorResponse, jakarta.servlet.http.HttpServletRequest, jakarta.servlet.http.HttpServletResponse, java.lang.Object).- Parameters:
- ex- the- NoResourceFoundExceptionto be handled
- request- current HTTP request
- response- current HTTP response
- handler- the resource handler
- Returns:
- an empty ModelAndViewindicating the exception was handled, ornullindicating the exception should be handled inhandleErrorResponse(org.springframework.web.ErrorResponse, jakarta.servlet.http.HttpServletRequest, jakarta.servlet.http.HttpServletResponse, java.lang.Object)
- Throws:
- IOException- potentially thrown from- HttpServletResponse.sendError(int, java.lang.String)
- Since:
- 6.1
 
- 
handleAsyncRequestTimeoutExceptionprotected @Nullable ModelAndView handleAsyncRequestTimeoutException(AsyncRequestTimeoutException ex, HttpServletRequest request, HttpServletResponse response, @Nullable Object handler) throws IOException Handle the case where an async request timed out.The default implementation returns nullin which case the exception is handled inhandleErrorResponse(org.springframework.web.ErrorResponse, jakarta.servlet.http.HttpServletRequest, jakarta.servlet.http.HttpServletResponse, java.lang.Object).- Parameters:
- ex- the- AsyncRequestTimeoutExceptionto be handled
- request- current HTTP request
- response- current HTTP response
- handler- the executed handler, or- nullif none chosen at the time of the exception (for example, if multipart resolution failed)
- Returns:
- an empty ModelAndViewindicating the exception was handled, ornullindicating the exception should be handled inhandleErrorResponse(org.springframework.web.ErrorResponse, jakarta.servlet.http.HttpServletRequest, jakarta.servlet.http.HttpServletResponse, java.lang.Object)
- Throws:
- IOException- potentially thrown from- HttpServletResponse.sendError(int, java.lang.String)
- Since:
- 4.2.8
 
- 
handleAsyncRequestNotUsableExceptionprotected ModelAndView handleAsyncRequestNotUsableException(AsyncRequestNotUsableException ex, HttpServletRequest request, HttpServletResponse response, @Nullable Object handler) Handle the case of an I/O failure from the ServletOutputStream.By default, do nothing since the response is not usable. - Parameters:
- ex- the- AsyncRequestTimeoutExceptionto be handled
- request- current HTTP request
- response- current HTTP response
- handler- the executed handler, or- nullif none chosen at the time of the exception (for example, if multipart resolution failed)
- Returns:
- an empty ModelAndView indicating the exception was handled
- Since:
- 5.3.33
 
- 
handleDisconnectedClientExceptionprotected ModelAndView handleDisconnectedClientException(Exception ex, HttpServletRequest request, HttpServletResponse response, @Nullable Object handler) Handle an Exception that indicates the client has gone away. This is typically anIOExceptionof a specific subtype or with a message specific to the underlying Servlet container. Those are detected throughDisconnectedClientHelper.isClientDisconnectedException(Throwable)By default, do nothing since the response is not usable. - Parameters:
- ex- the- Exceptionto be handled
- request- current HTTP request
- response- current HTTP response
- handler- the executed handler, or- nullif none chosen at the time of the exception (for example, if multipart resolution failed)
- Returns:
- an empty ModelAndView indicating the exception was handled
- Since:
- 6.2
 
- 
handleErrorResponseprotected ModelAndView handleErrorResponse(ErrorResponse errorResponse, HttpServletRequest request, HttpServletResponse response, @Nullable Object handler) throws IOException Handle anErrorResponseexception.The default implementation sets status and the headers of the response to those obtained from the ErrorResponse. If available, theProblemDetail.getDetail()is used as the message forHttpServletResponse.sendError(int, String).- Parameters:
- errorResponse- the exception to be handled
- request- current HTTP request
- response- current HTTP response
- handler- the executed handler
- Returns:
- an empty ModelAndViewindicating the exception was handled
- Throws:
- IOException- potentially thrown from- HttpServletResponse.sendError(int, java.lang.String)
- Since:
- 6.0
 
- 
handleConversionNotSupportedprotected ModelAndView handleConversionNotSupported(ConversionNotSupportedException ex, HttpServletRequest request, HttpServletResponse response, @Nullable Object handler) throws IOException Handle the case when aWebDataBinderconversion cannot occur.The default implementation sends an HTTP 500 error, and returns an empty ModelAndView. Alternatively, a fallback view could be chosen, or the ConversionNotSupportedException could be rethrown as-is.- Parameters:
- ex- the ConversionNotSupportedException to be handled
- request- current HTTP request
- response- current HTTP response
- handler- the executed handler
- Returns:
- an empty ModelAndViewindicating the exception was handled
- Throws:
- IOException- potentially thrown from- HttpServletResponse.sendError(int, java.lang.String)
 
- 
handleTypeMismatchprotected ModelAndView handleTypeMismatch(TypeMismatchException ex, HttpServletRequest request, HttpServletResponse response, @Nullable Object handler) throws IOException Handle the case when aWebDataBinderconversion error occurs.The default implementation sends an HTTP 400 error, and returns an empty ModelAndView. Alternatively, a fallback view could be chosen, or the TypeMismatchException could be rethrown as-is.- Parameters:
- ex- the TypeMismatchException to be handled
- request- current HTTP request
- response- current HTTP response
- handler- the executed handler
- Returns:
- an empty ModelAndViewindicating the exception was handled
- Throws:
- IOException- potentially thrown from- HttpServletResponse.sendError(int, java.lang.String)
 
- 
handleHttpMessageNotReadableprotected ModelAndView handleHttpMessageNotReadable(HttpMessageNotReadableException ex, HttpServletRequest request, HttpServletResponse response, @Nullable Object handler) throws IOException Handle the case where a message converter cannot read from an HTTP request.The default implementation sends an HTTP 400 error, and returns an empty ModelAndView. Alternatively, a fallback view could be chosen, or the HttpMessageNotReadableException could be rethrown as-is.- Parameters:
- ex- the HttpMessageNotReadableException to be handled
- request- current HTTP request
- response- current HTTP response
- handler- the executed handler
- Returns:
- an empty ModelAndViewindicating the exception was handled
- Throws:
- IOException- potentially thrown from- HttpServletResponse.sendError(int, java.lang.String)
 
- 
handleHttpMessageNotWritableprotected ModelAndView handleHttpMessageNotWritable(HttpMessageNotWritableException ex, HttpServletRequest request, HttpServletResponse response, @Nullable Object handler) throws IOException Handle the case where a message converter cannot write to an HTTP response.The default implementation sends an HTTP 500 error, and returns an empty ModelAndView. Alternatively, a fallback view could be chosen, or the HttpMessageNotWritableException could be rethrown as-is.- Parameters:
- ex- the HttpMessageNotWritableException to be handled
- request- current HTTP request
- response- current HTTP response
- handler- the executed handler
- Returns:
- an empty ModelAndViewindicating the exception was handled
- Throws:
- IOException- potentially thrown from- HttpServletResponse.sendError(int, java.lang.String)
 
- 
handleMethodValidationExceptionprotected ModelAndView handleMethodValidationException(MethodValidationException ex, HttpServletRequest request, HttpServletResponse response, @Nullable Object handler) throws IOException Handle the case where method validation failed on a component that is not a web controller, for example, on some underlying service.The default implementation sends an HTTP 500 error, and returns an empty ModelAndView. Alternatively, a fallback view could be chosen, or the HttpMessageNotWritableException could be rethrown as-is.- Parameters:
- ex- the exception to be handled
- request- current HTTP request
- response- current HTTP response
- handler- the executed handler
- Returns:
- an empty ModelAndViewindicating the exception was handled
- Throws:
- IOException- potentially thrown from- HttpServletResponse.sendError(int, java.lang.String)
- Since:
- 6.1
 
- 
sendServerErrorprotected void sendServerError(Exception ex, HttpServletRequest request, HttpServletResponse response) throws IOException Invoked to send a server error. Sets the status to 500 and also sets the request attribute "jakarta.servlet.error.exception" to the Exception.- Throws:
- IOException
 
- 
logExceptionDescription copied from class:AbstractHandlerExceptionResolverLog the given exception at warn level, provided that warn logging has been activated through the"warnLogCategory"property.Calls AbstractHandlerExceptionResolver.buildLogMessage(java.lang.Exception, jakarta.servlet.http.HttpServletRequest)in order to determine the concrete message to log.- Overrides:
- logExceptionin class- AbstractHandlerExceptionResolver
- Parameters:
- ex- the exception that got thrown during handler execution
- request- current HTTP request (useful for obtaining metadata)
- See Also:
 
 
-