Class SimpleMappingExceptionResolver
java.lang.Object
org.springframework.web.servlet.handler.AbstractHandlerExceptionResolver
org.springframework.web.servlet.handler.SimpleMappingExceptionResolver
- All Implemented Interfaces:
Ordered, HandlerExceptionResolver
HandlerExceptionResolver implementation
that allows for mapping exception class names to view names, either for a set of
given handlers or for all handlers in the DispatcherServlet.
Error views are analogous to error page JSPs, but can be used with any kind of exception including any checked one, with fine-granular mappings for specific handlers.
- Since:
- 22.11.2003
- Author:
- Juergen Hoeller, Arjen Poutsma, Rossen Stoyanchev
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe default name of the exception attribute: "exception".Fields inherited from class AbstractHandlerExceptionResolver
loggerFields inherited from interface Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddStatusCode(String viewName, int statusCode) An alternative tosetStatusCodes(Properties)for use with Java-based configuration.protected voidapplyStatusCodeIfPossible(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, int statusCode) Apply the specified HTTP status code to the given response, if possible (that is, if not executing within an include request).determineStatusCode(jakarta.servlet.http.HttpServletRequest request, String viewName) Determine the HTTP status code to apply for the given error view.determineViewName(Exception ex, jakarta.servlet.http.HttpServletRequest request) Determine the view name for the given exception, first checking against the"excludedExecptions", then searching the"exceptionMappings", and finally using the"defaultErrorView"as a fallback.protected @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 on handler execution, returning a ModelAndView that represents a specific error page if appropriate.findMatchingViewName(Properties exceptionMappings, Exception ex) Find a matching view name in the given exception mappings.protected intReturn the depth to the superclass matching.protected ModelAndViewgetModelAndView(String viewName, Exception ex) Return a ModelAndView for the given view name and exception.protected ModelAndViewgetModelAndView(String viewName, Exception ex, jakarta.servlet.http.HttpServletRequest request) Return a ModelAndView for the given request, view name and exception.Returns the HTTP status codes provided viasetStatusCodes(Properties).voidsetDefaultErrorView(String defaultErrorView) Set the name of the default error view.voidsetDefaultStatusCode(int defaultStatusCode) Set the default HTTP status code that this exception resolver will apply if it resolves an error view and if there is no status code mapping defined.voidsetExceptionAttribute(@Nullable String exceptionAttribute) Set the name of the model attribute as which the exception should be exposed.voidsetExceptionMappings(Properties mappings) Set the mappings between exception class names and error view names.voidsetExcludedExceptions(Class<?>... excludedExceptions) Set one or more exceptions to be excluded from the exception mappings.voidsetStatusCodes(Properties statusCodes) Set the HTTP status code that this exception resolver will apply for a given resolved error view.Methods inherited from class AbstractHandlerExceptionResolver
addMappedHandlerClass, buildLogMessage, getMappedHandlerClasses, getOrder,