org.springframework.web.servlet.handler
Class AbstractHandlerMethodExceptionResolver

java.lang.Object
  extended by org.springframework.web.servlet.handler.AbstractHandlerExceptionResolver
      extended by org.springframework.web.servlet.handler.AbstractHandlerMethodExceptionResolver
All Implemented Interfaces:
Ordered, HandlerExceptionResolver
Direct Known Subclasses:
ExceptionHandlerExceptionResolver

public class AbstractHandlerMethodExceptionResolver
extends AbstractHandlerExceptionResolver

Abstract base class for HandlerExceptionResolver implementations that support handling exceptions from HandlerMethods rather than handlers.

Since:
3.1
Author:
Rossen Stoyanchev

Field Summary
 
Fields inherited from class org.springframework.web.servlet.handler.AbstractHandlerExceptionResolver
logger
 
Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
 
Constructor Summary
AbstractHandlerMethodExceptionResolver()
           
 
Method Summary
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.
protected  ModelAndView doResolveHandlerMethodException(HttpServletRequest request, HttpServletResponse response, HandlerMethod handlerMethod, 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.
protected  boolean shouldApplyTo(HttpServletRequest request, Object handler)
          Checks if the handler is a HandlerMethod instance and performs the check against the bean instance it contains.
 
Methods inherited from class org.springframework.web.servlet.handler.AbstractHandlerExceptionResolver
buildLogMessage, getOrder, logException, prepareResponse, preventCaching, resolveException, setMappedHandlerClasses, setMappedHandlers, setOrder, setPreventResponseCaching, setWarnLogCategory
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractHandlerMethodExceptionResolver

public AbstractHandlerMethodExceptionResolver()
Method Detail

shouldApplyTo

protected boolean shouldApplyTo(HttpServletRequest request,
                                Object handler)
Checks if the handler is a HandlerMethod instance and performs the check against the bean instance it contains. If the provided handler is not an instance of HandlerMethod, false is returned instead.

Overrides:
shouldApplyTo in class AbstractHandlerExceptionResolver
Parameters:
request - current HTTP request
handler - the executed handler, or null if none chosen at the time of the exception (for example, if multipart resolution failed)
Returns:
whether this resolved should proceed with resolving the exception for the given request and handler
See Also:
AbstractHandlerExceptionResolver.setMappedHandlers(java.util.Set), AbstractHandlerExceptionResolver.setMappedHandlerClasses(java.lang.Class[])

doResolveException

protected final ModelAndView doResolveException(HttpServletRequest request,
                                                HttpServletResponse response,
                                                Object handler,
                                                Exception ex)
Description copied from class: AbstractHandlerExceptionResolver
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.

Specified by:
doResolveException in class AbstractHandlerExceptionResolver
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

doResolveHandlerMethodException

protected ModelAndView doResolveHandlerMethodException(HttpServletRequest request,
                                                       HttpServletResponse response,
                                                       HandlerMethod handlerMethod,
                                                       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
handlerMethod - the executed handler method, 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