Top Description Fields Constructors Methods
org.springframework.web.servlet.handler

public abstract Class AbstractHandlerMethodExceptionResolver

extends AbstractHandlerExceptionResolver
Class Inheritance
Known Direct Subclasses
org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver
Imports
jakarta.servlet.http.HttpServletRequest, .HttpServletResponse, org.springframework.lang.Nullable, org.springframework.web.method.HandlerMethod, org.springframework.web.servlet.ModelAndView

Abstract base class for HandlerExceptionResolver implementations that support handling exceptions from handlers of type HandlerMethod.
Author
Rossen Stoyanchev
Since
3.1

Field Summary

Inherited from org.springframework.web.servlet.handler.AbstractHandlerExceptionResolver:
logger

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected final ModelAndView
doResolveException(HttpServletRequest
current HTTP request
request
,
HttpServletResponse
current HTTP response
response
,
Object
the executed handler, or null if none chosen at the time of the exception (for example, if multipart resolution failed)
handler
,
Exception
the exception that got thrown during handler execution
ex
)

Implements abstract org.springframework.web.servlet.handler.AbstractHandlerExceptionResolver.doResolveException.

Actually resolve the given exception that got thrown during handler execution, returning a ModelAndView that represents a specific error page if appropriate.

protected abstract ModelAndView

Returns:

a corresponding ModelAndView to forward to, or null for default processing
doResolveHandlerMethodException
(HttpServletRequest
current HTTP request
request
,
HttpServletResponse
current HTTP response
response
,
HandlerMethod
the executed handler method, or null if none chosen at the time of the exception (for example, if multipart resolution failed)
handlerMethod
,
Exception
the exception that got thrown during handler execution
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
hasGlobalExceptionHandlers()

Whether this resolver has global exception handlers, e.g. not declared in the same class as the HandlerMethod that raised the exception and therefore can apply to any handler.

protected boolean
shouldApplyTo(HttpServletRequest
current HTTP request
request
,
Object
the executed handler, or null if none chosen at the time of the exception (for example, if multipart resolution failed)
handler
)

Overrides org.springframework.web.servlet.handler.AbstractHandlerExceptionResolver.shouldApplyTo.

Checks if the handler is a HandlerMethod and then delegates to the base class implementation of #shouldApplyTo(HttpServletRequest, Object) passing the bean of the HandlerMethod.

Inherited from org.springframework.web.servlet.handler.AbstractHandlerExceptionResolver:
addMappedHandlerClassbuildLogMessagegetMappedHandlerClassesgetOrderhasHandlerMappingslogExceptionprepareResponsepreventCachingresolveExceptionsetMappedHandlerClassessetMappedHandlerPredicatesetMappedHandlerssetOrdersetPreventResponseCachingsetWarnLogCategory

Constructor Detail

AbstractHandlerMethodExceptionResolverback to summary
public AbstractHandlerMethodExceptionResolver()

Method Detail

doResolveExceptionback to summary
protected final ModelAndView doResolveException(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex)

Implements abstract org.springframework.web.servlet.handler.AbstractHandlerExceptionResolver.doResolveException.

Doc from org.springframework.web.servlet.handler.AbstractHandlerExceptionResolver.doResolveException.

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

Parameters
request:HttpServletRequest

current HTTP request

response:HttpServletResponse

current HTTP response

handler:Object

the executed handler, or null if none chosen at the time of the exception (for example, if multipart resolution failed)

ex:Exception

the exception that got thrown during handler execution

Returns:ModelAndView

a corresponding ModelAndView to forward to, or null for default processing in the resolution chain

Annotations
@Override
@Nullable
doResolveHandlerMethodExceptionback to summary
protected abstract 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:HttpServletRequest

current HTTP request

response:HttpServletResponse

current HTTP response

handlerMethod:HandlerMethod

the executed handler method, or null if none chosen at the time of the exception (for example, if multipart resolution failed)

ex:Exception

the exception that got thrown during handler execution

Returns:ModelAndView

a corresponding ModelAndView to forward to, or null for default processing

Annotations
@Nullable
hasGlobalExceptionHandlersback to summary
protected boolean hasGlobalExceptionHandlers()

Whether this resolver has global exception handlers, e.g. not declared in the same class as the HandlerMethod that raised the exception and therefore can apply to any handler.

Since
5.3
shouldApplyToback to summary
protected boolean shouldApplyTo(HttpServletRequest request, Object handler)

Overrides org.springframework.web.servlet.handler.AbstractHandlerExceptionResolver.shouldApplyTo.

Checks if the handler is a HandlerMethod and then delegates to the base class implementation of #shouldApplyTo(HttpServletRequest, Object) passing the bean of the HandlerMethod. Otherwise returns false.

Parameters
request:HttpServletRequest

Doc from org.springframework.web.servlet.handler.AbstractHandlerExceptionResolver.shouldApplyTo.

current HTTP request

handler:Object

Doc from org.springframework.web.servlet.handler.AbstractHandlerExceptionResolver.shouldApplyTo.

the executed handler, or null if none chosen at the time of the exception (for example, if multipart resolution failed)

Returns:boolean

Doc from org.springframework.web.servlet.handler.AbstractHandlerExceptionResolver.shouldApplyTo.

whether this resolved should proceed with resolving the exception for the given request and handler

Annotations
@Override