public class DefaultErrorResolver extends Object implements ErrorResolver
| 限定符和类型 | 字段和说明 |
|---|---|
static String |
PAGE_NOT_FOUND_LOG_CATEGORY
Log category to use when no mapped handler is found for a request.
|
protected static org.apache.commons.logging.Log |
pageNotFoundLogger
Additional logger to use when no mapped handler is found for a request.
|
| 构造器和说明 |
|---|
DefaultErrorResolver() |
| 限定符和类型 | 方法和说明 |
|---|---|
protected org.springframework.http.ResponseEntity<ErrorResponse> |
handleBindException(org.springframework.validation.BindException ex,
Object handler,
boolean developerMode)
Handle the case where an @ModelAttribute
method argument has binding or validation errors and is not followed by
another method argument of type
BindingResult. |
protected org.springframework.http.ResponseEntity<ErrorResponse> |
handleConversionNotSupported(org.springframework.beans.ConversionNotSupportedException ex,
Object handler,
boolean developerMode)
Handle the case when a
WebDataBinder
conversion cannot occur. |
protected org.springframework.http.ResponseEntity<ErrorResponse> |
handleHttpMediaTypeNotAcceptable(org.springframework.web.HttpMediaTypeNotAcceptableException ex,
Object handler,
boolean developerMode)
Handle the case where no
message converters were found that were acceptable for the client
(expressed via the
Accept header. |
protected org.springframework.http.ResponseEntity<ErrorResponse> |
handleHttpMediaTypeNotSupported(org.springframework.web.HttpMediaTypeNotSupportedException ex,
Object handler,
boolean developerMode)
Handle the case where no
message converters were found for the PUT or POSTed content.
|
protected org.springframework.http.ResponseEntity<ErrorResponse> |
handleHttpMessageNotReadable(org.springframework.http.converter.HttpMessageNotReadableException ex,
Object handler,
boolean developerMode)
Handle the case where a
message converter cannot read from a HTTP request.
|
protected org.springframework.http.ResponseEntity<ErrorResponse> |
handleHttpMessageNotWritable(org.springframework.http.converter.HttpMessageNotWritableException ex,
Object handler,
boolean developerMode)
Handle the case where a
message converter cannot write to a HTTP request.
|
protected org.springframework.http.ResponseEntity<ErrorResponse> |
handleHttpRequestMethodNotSupported(org.springframework.web.HttpRequestMethodNotSupportedException ex,
Object handler,
boolean developerMode)
Handle the case where no request handler method was found for the
particular HTTP request method.
|
protected org.springframework.http.ResponseEntity<ErrorResponse> |
handleInternalServerError(org.springframework.beans.ConversionNotSupportedException ex,
Object handler,
boolean developerMode)
Handle the case when the un-supported exceptions occur
The default implementation sends an HTTP 500 error, and returns an empty
ModelAndView. |
protected org.springframework.http.ResponseEntity<ErrorResponse> |
handleMethodArgumentNotValidException(org.springframework.web.bind.MethodArgumentNotValidException ex,
Object handler,
boolean developerMode)
Handle the case where an argument annotated with
@Valid such as
an RequestBody or RequestPart argument fails validation. |
protected org.springframework.http.ResponseEntity<ErrorResponse> |
handleMissingServletRequestParameter(org.springframework.web.bind.MissingServletRequestParameterException ex,
Object handler,
boolean developerMode)
Handle the case when a required parameter is missing.
|
protected org.springframework.http.ResponseEntity<ErrorResponse> |
handleMissingServletRequestPartException(org.springframework.web.multipart.support.MissingServletRequestPartException ex,
Object handler,
boolean developerMode)
Handle the case where an @RequestPart, a
MultipartFile, or a javax.servlet.http.Part argument is
required but is missing. |
protected org.springframework.http.ResponseEntity<ErrorResponse> |
handleNoHandlerFoundException(org.springframework.web.servlet.NoHandlerFoundException ex,
Object handler,
boolean developerMode)
Handle the case where no handler was found during the dispatch.
|
protected org.springframework.http.ResponseEntity<ErrorResponse> |
handleNoSuchRequestHandlingMethod(org.springframework.web.servlet.mvc.multiaction.NoSuchRequestHandlingMethodException ex,
Object handler,
boolean developerMode)
Handle the case where no request handler method was found.
|
protected org.springframework.http.ResponseEntity<ErrorResponse> |
handleServletRequestBindingException(org.springframework.web.bind.ServletRequestBindingException ex,
Object handler,
boolean developerMode)
Handle the case when an unrecoverable binding exception occurs - e.g.
|
protected org.springframework.http.ResponseEntity<ErrorResponse> |
handleTypeMismatch(org.springframework.beans.TypeMismatchException ex,
Object handler,
boolean developerMode)
Handle the case when a
WebDataBinder
conversion error occurs. |
org.springframework.http.ResponseEntity |
resolve(ErrorContext errorContext) |
public static final String PAGE_NOT_FOUND_LOG_CATEGORY
pageNotFoundLogger,
常量字段值protected static final org.apache.commons.logging.Log pageNotFoundLogger
public org.springframework.http.ResponseEntity resolve(ErrorContext errorContext)
resolve 在接口中 ErrorResolverprotected org.springframework.http.ResponseEntity<ErrorResponse> handleNoSuchRequestHandlingMethod(org.springframework.web.servlet.mvc.multiaction.NoSuchRequestHandlingMethodException ex, Object handler, boolean developerMode) throws IOException
The default implementation logs a warning, sends an HTTP 404 error, and
returns an empty ModelAndView. Alternatively, a fallback view
could be chosen, or the NoSuchRequestHandlingMethodException could be
rethrown as-is.
ex - the NoSuchRequestHandlingMethodException to be handledhandler - the executed handler, or null if none chosen at the
time of the exception (for example, if multipart resolution
failed)IOException - potentially thrown from response.sendError()protected org.springframework.http.ResponseEntity<ErrorResponse> handleHttpRequestMethodNotSupported(org.springframework.web.HttpRequestMethodNotSupportedException ex, Object handler, boolean developerMode) throws IOException
The default implementation logs a warning, sends an HTTP 405 error, sets
the "Allow" header, and returns an empty ModelAndView.
Alternatively, a fallback view could be chosen, or the
HttpRequestMethodNotSupportedException could be rethrown as-is.
ex - the HttpRequestMethodNotSupportedException to be handledhandler - the executed handler, or null if none chosen at the
time of the exception (for example, if multipart resolution
failed)IOException - potentially thrown from response.sendError()protected org.springframework.http.ResponseEntity<ErrorResponse> handleHttpMediaTypeNotSupported(org.springframework.web.HttpMediaTypeNotSupportedException ex, Object handler, boolean developerMode) throws IOException
The default implementation sends an HTTP 415 error, sets the "Accept"
header, and returns an empty ModelAndView. Alternatively, a
fallback view could be chosen, or the HttpMediaTypeNotSupportedException
could be rethrown as-is.
ex - the HttpMediaTypeNotSupportedException to be handledhandler - the executed handlerIOException - potentially thrown from response.sendError()protected org.springframework.http.ResponseEntity<ErrorResponse> handleHttpMediaTypeNotAcceptable(org.springframework.web.HttpMediaTypeNotAcceptableException ex, Object handler, boolean developerMode) throws IOException
Accept header.
The default implementation sends an HTTP 406 error and returns an empty
ModelAndView. Alternatively, a fallback view could be chosen, or
the HttpMediaTypeNotAcceptableException could be rethrown as-is.
ex - the HttpMediaTypeNotAcceptableException to be handledhandler - the executed handlerIOException - potentially thrown from response.sendError()protected org.springframework.http.ResponseEntity<ErrorResponse> handleMissingServletRequestParameter(org.springframework.web.bind.MissingServletRequestParameterException ex, Object handler, boolean developerMode) throws IOException
The default implementation sends an HTTP 400 error, and returns an empty
ModelAndView. Alternatively, a fallback view could be chosen, or
the MissingServletRequestParameterException could be rethrown as-is.
ex - the MissingServletRequestParameterException to be handledhandler - the executed handlerIOException - potentially thrown from response.sendError()protected org.springframework.http.ResponseEntity<ErrorResponse> handleServletRequestBindingException(org.springframework.web.bind.ServletRequestBindingException ex, Object handler, boolean developerMode) throws IOException
The default implementation sends an HTTP 400 error, and returns an empty
ModelAndView. Alternatively, a fallback view could be chosen, or
the exception could be rethrown as-is.
ex - the exception to be handledhandler - the executed handlerIOException - potentially thrown from response.sendError()protected org.springframework.http.ResponseEntity<ErrorResponse> handleConversionNotSupported(org.springframework.beans.ConversionNotSupportedException ex, Object handler, boolean developerMode) throws IOException
WebDataBinder
conversion cannot occur.
The default implementation sends an HTTP 500 error, and returns an empty
ModelAndView. Alternatively, a fallback view could be chosen, or
the TypeMismatchException could be rethrown as-is.
ex - the ConversionNotSupportedException to be handledhandler - the executed handlerIOException - potentially thrown from response.sendError()protected org.springframework.http.ResponseEntity<ErrorResponse> handleInternalServerError(org.springframework.beans.ConversionNotSupportedException ex, Object handler, boolean developerMode) throws IOException
The default implementation sends an HTTP 500 error, and returns an empty
ModelAndView.
ex - the un-supported exception to be handledhandler - the executed handlerIOException - potentially thrown from response.sendError()protected org.springframework.http.ResponseEntity<ErrorResponse> handleTypeMismatch(org.springframework.beans.TypeMismatchException ex, Object handler, boolean developerMode) throws IOException
WebDataBinder
conversion 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.
ex - the TypeMismatchException to be handledhandler - the executed handlerIOException - potentially thrown from response.sendError()protected org.springframework.http.ResponseEntity<ErrorResponse> handleHttpMessageNotReadable(org.springframework.http.converter.HttpMessageNotReadableException ex, Object handler, boolean developerMode) throws IOException
The default implementation sends an HTTP 400 error, and returns an empty
ModelAndView. Alternatively, a fallback view could be chosen, or
the HttpMediaTypeNotSupportedException could be rethrown as-is.
ex - the HttpMessageNotReadableException to be handledhandler - the executed handlerIOException - potentially thrown from response.sendError()protected org.springframework.http.ResponseEntity<ErrorResponse> handleHttpMessageNotWritable(org.springframework.http.converter.HttpMessageNotWritableException ex, Object handler, boolean developerMode) throws IOException
The default implementation sends an HTTP 500 error, and returns an empty
ModelAndView. Alternatively, a fallback view could be chosen, or
the HttpMediaTypeNotSupportedException could be rethrown as-is.
ex - the HttpMessageNotWritableException to be handledhandler - the executed handlerIOException - potentially thrown from response.sendError()protected org.springframework.http.ResponseEntity<ErrorResponse> handleMethodArgumentNotValidException(org.springframework.web.bind.MethodArgumentNotValidException ex, Object handler, boolean developerMode) throws IOException
@Valid such as
an RequestBody or RequestPart argument fails validation.
An HTTP 400 error is sent back to the client.handler - the executed handlerIOException - potentially thrown from response.sendError()protected org.springframework.http.ResponseEntity<ErrorResponse> handleBindException(org.springframework.validation.BindException ex, Object handler, boolean developerMode) throws IOException
BindingResult. By default an HTTP
400 error is sent back to the client.handler - the executed handlerIOException - potentially thrown from response.sendError()protected org.springframework.http.ResponseEntity<ErrorResponse> handleMissingServletRequestPartException(org.springframework.web.multipart.support.MissingServletRequestPartException ex, Object handler, boolean developerMode) throws IOException
MultipartFile, or a javax.servlet.http.Part argument is
required but is missing. An HTTP 400 error is sent back to the client.handler - the executed handlerIOException - potentially thrown from response.sendError()protected org.springframework.http.ResponseEntity<ErrorResponse> handleNoHandlerFoundException(org.springframework.web.servlet.NoHandlerFoundException ex, Object handler, boolean developerMode) throws IOException
The default sends an HTTP 404 error, and returns an empty
ModelAndView. Alternatively, a fallback view could be chosen, or
the NoHandlerFoundException could be rethrown as-is.
ex - the NoHandlerFoundException to be handledhandler - the executed handler, or null if none chosen at the
time of the exception (for example, if multipart resolution
failed)IOException - potentially thrown from response.sendError()Copyright © 2015. All rights reserved.