public class

DefaultHandlerExceptionResolver

extends AbstractHandlerExceptionResolver
java.lang.Object
   ↳ org.springframework.web.servlet.handler.AbstractHandlerExceptionResolver
     ↳ org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver

Summary

Constants
String PAGE_NOT_FOUND_LOG_CATEGORY Log category to use when no mapped handler is found for a request.
[Expand]
Inherited Constants
From interface org.springframework.core.Ordered
Fields
protected static final Log pageNotFoundLogger Additional logger to use when no mapped handler is found for a request.
[Expand]
Inherited Fields
From class org.springframework.web.servlet.handler.AbstractHandlerExceptionResolver
Public Constructors
DefaultHandlerExceptionResolver()
Protected Methods
ModelAndView doResolveException(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex)
Actually resolve the given exception that got thrown during on handler execution, returning a ModelAndView that represents a specific error page if appropriate.
ModelAndView handleConversionNotSupported(ConversionNotSupportedException ex, HttpServletRequest request, HttpServletResponse response, Object handler)
Handle the case when a WebDataBinder conversion cannot occur.
ModelAndView handleHttpMediaTypeNotAcceptable(HttpMediaTypeNotAcceptableException ex, HttpServletRequest request, HttpServletResponse response, Object handler)
Handle the case where no message converters were found that were acceptable for the client (expressed via the Accept header.
ModelAndView handleHttpMediaTypeNotSupported(HttpMediaTypeNotSupportedException ex, HttpServletRequest request, HttpServletResponse response, Object handler)
Handle the case where no message converters were found for the PUT or POSTed content.
ModelAndView handleHttpMessageNotReadable(HttpMessageNotReadableException ex, HttpServletRequest request, HttpServletResponse response, Object handler)
Handle the case where a message converter cannot read from a HTTP request.
ModelAndView handleHttpMessageNotWritable(HttpMessageNotWritableException ex, HttpServletRequest request, HttpServletResponse response, Object handler)
Handle the case where a message converter cannot write to a HTTP request.
ModelAndView handleHttpRequestMethodNotSupported(HttpRequestMethodNotSupportedException ex, HttpServletRequest request, HttpServletResponse response, Object handler)
Handle the case where no request handler method was found for the particular HTTP request method.
ModelAndView handleMissingServletRequestParameter(MissingServletRequestParameterException ex, HttpServletRequest request, HttpServletResponse response, Object handler)
Handle the case when a required parameter is missing.
ModelAndView handleNoSuchRequestHandlingMethod(NoSuchRequestHandlingMethodException ex, HttpServletRequest request, HttpServletResponse response, Object handler)
Handle the case where no request handler method was found.
ModelAndView handleTypeMismatch(TypeMismatchException ex, HttpServletRequest request, HttpServletResponse response, Object handler)
Handle the case when a WebDataBinder conversion error occurs.
[Expand]
Inherited Methods
From class org.springframework.web.servlet.handler.AbstractHandlerExceptionResolver
From class java.lang.Object
From interface org.springframework.core.Ordered
From interface org.springframework.web.servlet.HandlerExceptionResolver

Constants

public static final String PAGE_NOT_FOUND_LOG_CATEGORY

Log category to use when no mapped handler is found for a request.

Constant Value: "org.springframework.web.servlet.PageNotFound"

Fields

protected static final Log pageNotFoundLogger

Additional logger to use when no mapped handler is found for a request.

Public Constructors

public DefaultHandlerExceptionResolver ()

Sets the order to LOWEST_PRECEDENCE.

Protected Methods

protected ModelAndView doResolveException (HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex)

Actually resolve the given exception that got thrown during on handler execution, returning a ModelAndView that 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 resolved applies ("mappedHandlers" etc), so an implementation may simply proceed with its actual exception handling.

Parameters
request current HTTP request
response current HTTP response
handler the executed handler, or null if 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 ModelAndView to forward to, or null for default processing

protected ModelAndView handleConversionNotSupported (ConversionNotSupportedException ex, HttpServletRequest request, HttpServletResponse response, Object handler)

Handle the case when a 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.

Parameters
ex the ConversionNotSupportedException to be handled
request current HTTP request
response current HTTP response
handler the executed handler, or null if none chosen at the time of the exception (for example, if multipart resolution failed)
Returns
  • a ModelAndView to render, or null if handled directly
Throws
Exception an Exception that should be thrown as result of the servlet request

protected ModelAndView handleHttpMediaTypeNotAcceptable (HttpMediaTypeNotAcceptableException ex, HttpServletRequest request, HttpServletResponse response, Object handler)

Handle the case where no message converters were found that were acceptable for the client (expressed via the 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.

Parameters
ex the HttpMediaTypeNotAcceptableException to be handled
request current HTTP request
response current HTTP response
handler the executed handler, or null if none chosen at the time of the exception (for example, if multipart resolution failed)
Returns
  • a ModelAndView to render, or null if handled directly
Throws
Exception an Exception that should be thrown as result of the servlet request

protected ModelAndView handleHttpMediaTypeNotSupported (HttpMediaTypeNotSupportedException ex, HttpServletRequest request, HttpServletResponse response, Object handler)

Handle the case where no message converters were found for the PUT or POSTed content.

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.

Parameters
ex the HttpMediaTypeNotSupportedException to be handled
request current HTTP request
response current HTTP response
handler the executed handler, or null if none chosen at the time of the exception (for example, if multipart resolution failed)
Returns
  • a ModelAndView to render, or null if handled directly
Throws
Exception an Exception that should be thrown as result of the servlet request

protected ModelAndView handleHttpMessageNotReadable (HttpMessageNotReadableException ex, HttpServletRequest request, HttpServletResponse response, Object handler)

Handle the case where a message converter cannot read from a HTTP request.

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.

Parameters
ex the HttpMessageNotReadableException to be handled
request current HTTP request
response current HTTP response
handler the executed handler, or null if none chosen at the time of the exception (for example, if multipart resolution failed)
Returns
  • a ModelAndView to render, or null if handled directly
Throws
Exception an Exception that should be thrown as result of the servlet request

protected ModelAndView handleHttpMessageNotWritable (HttpMessageNotWritableException ex, HttpServletRequest request, HttpServletResponse response, Object handler)

Handle the case where a message converter cannot write to a HTTP request.

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.

Parameters
ex the HttpMessageNotWritableException to be handled
request current HTTP request
response current HTTP response
handler the executed handler, or null if none chosen at the time of the exception (for example, if multipart resolution failed)
Returns
  • a ModelAndView to render, or null if handled directly
Throws
Exception an Exception that should be thrown as result of the servlet request

protected ModelAndView handleHttpRequestMethodNotSupported (HttpRequestMethodNotSupportedException ex, HttpServletRequest request, HttpServletResponse response, Object handler)

Handle the case where no request handler method was found for the particular HTTP request method.

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.

Parameters
ex the HttpRequestMethodNotSupportedException to be handled
request current HTTP request
response current HTTP response
handler the executed handler, or null if none chosen at the time of the exception (for example, if multipart resolution failed)
Returns
  • a ModelAndView to render, or null if handled directly
Throws
Exception an Exception that should be thrown as result of the servlet request

protected ModelAndView handleMissingServletRequestParameter (MissingServletRequestParameterException ex, HttpServletRequest request, HttpServletResponse response, Object handler)

Handle the case when a required parameter is missing.

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.

Parameters
ex the MissingServletRequestParameterException to be handled
request current HTTP request
response current HTTP response
handler the executed handler, or null if none chosen at the time of the exception (for example, if multipart resolution failed)
Returns
  • a ModelAndView to render, or null if handled directly
Throws
Exception an Exception that should be thrown as result of the servlet request

protected ModelAndView handleNoSuchRequestHandlingMethod (NoSuchRequestHandlingMethodException ex, HttpServletRequest request, HttpServletResponse response, Object handler)

Handle the case where no request handler method was found.

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.

Parameters
ex the NoSuchRequestHandlingMethodException to be handled
request current HTTP request
response current HTTP response
handler the executed handler, or null if none chosen at the time of the exception (for example, if multipart resolution failed)
Returns
  • a ModelAndView to render, or null if handled directly
Throws
Exception an Exception that should be thrown as result of the servlet request

protected ModelAndView handleTypeMismatch (TypeMismatchException ex, HttpServletRequest request, HttpServletResponse response, Object handler)

Handle the case when a 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.

Parameters
ex the TypeMismatchException to be handled
request current HTTP request
response current HTTP response
handler the executed handler, or null if none chosen at the time of the exception (for example, if multipart resolution failed)
Returns
  • a ModelAndView to render, or null if handled directly
Throws
Exception an Exception that should be thrown as result of the servlet request