Class AbstractHandlerMethodExceptionResolver
java.lang.Object
org.springframework.web.servlet.handler.AbstractHandlerExceptionResolver
org.springframework.web.servlet.handler.AbstractHandlerMethodExceptionResolver
- All Implemented Interfaces:
- Ordered, HandlerExceptionResolver
- Direct Known Subclasses:
- ExceptionHandlerExceptionResolver
public abstract class AbstractHandlerMethodExceptionResolver
extends AbstractHandlerExceptionResolver
Abstract base class for
HandlerExceptionResolver
implementations that support handling exceptions from handlers of type HandlerMethod.- Since:
- 3.1
- Author:
- Rossen Stoyanchev, Juergen Hoeller
- 
Field SummaryFields inherited from class AbstractHandlerExceptionResolverloggerFields inherited from interface OrderedHIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionprotected final @Nullable ModelAndViewdoResolveException(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.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 abstract @Nullable ModelAndViewdoResolveHandlerMethodException(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, @Nullable 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 booleanWhether this resolver has global exception handlers, for example, not declared in the same class as theHandlerMethodthat raised the exception and therefore can apply to any handler.protected booleanshouldApplyTo(jakarta.servlet.http.HttpServletRequest request, @Nullable Object handler) Checks if the handler is aHandlerMethodor the resolver has global exception handlers and then delegates to the base class implementation of#shouldApplyTopassing the bean of theHandlerMethodif necessary.Methods inherited from class AbstractHandlerExceptionResolveraddMappedHandlerClass, buildLogMessage, getMappedHandlerClasses, getOrder, hasHandlerMappings, logException, prepareResponse, preventCaching, resolveException, setMappedHandlerClasses, setMappedHandlerPredicate, setMappedHandlers, setOrder, setPreventResponseCaching, setWarnLogCategory
- 
Constructor Details- 
AbstractHandlerMethodExceptionResolverpublic AbstractHandlerMethodExceptionResolver()
 
- 
- 
Method Details- 
shouldApplyToprotected boolean shouldApplyTo(jakarta.servlet.http.HttpServletRequest request, @Nullable Object handler) Checks if the handler is aHandlerMethodor the resolver has global exception handlers and then delegates to the base class implementation of#shouldApplyTopassing the bean of theHandlerMethodif necessary. Otherwise, returnsfalse.- Overrides:
- shouldApplyToin class- AbstractHandlerExceptionResolver
- Parameters:
- request- current HTTP request
- handler- the executed handler, or- nullif 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:
 
- 
hasGlobalExceptionHandlersprotected boolean hasGlobalExceptionHandlers()Whether this resolver has global exception handlers, for example, not declared in the same class as theHandlerMethodthat raised the exception and therefore can apply to any handler.- Since:
- 5.3
 
- 
doResolveExceptionprotected final @Nullable ModelAndView doResolveException(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.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
 
- 
doResolveHandlerMethodExceptionprotected abstract @Nullable ModelAndView doResolveHandlerMethodException(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, @Nullable 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- 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 ModelAndView to forward to, or nullfor default processing
 
 
-