open class SimpleMappingExceptionResolver : AbstractHandlerExceptionResolver
org.springframework.web.servlet.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.
Author
Juergen Hoeller
Author
Arjen Poutsma
Author
Rossen Stoyanchev
Since
22.11.2003
See Also
org.springframework.web.servlet.DispatcherServlet
SimpleMappingExceptionResolver()
org.springframework.web.servlet.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. |
static val DEFAULT_EXCEPTION_ATTRIBUTE: String
The default name of the exception attribute: "exception". |
open fun addStatusCode(viewName: String, statusCode: Int): Unit
An alternative to |
|
open fun getStatusCodesAsMap(): MutableMap<String, Int>
Returns the HTTP status codes provided via |
|
open fun setDefaultErrorView(defaultErrorView: String): Unit
Set the name of the default error view. This view will be returned if no specific mapping was found. Default is none. |
|
open fun setDefaultStatusCode(defaultStatusCode: Int): Unit
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. Note that this error code will only get applied in case of a top-level request. It will not be set for an include request, since the HTTP status cannot be modified from within an include. If not specified, no status code will be applied, either leaving this to the controller or view, or keeping the servlet engine's default of 200 (OK). |
|
open fun setExceptionAttribute(exceptionAttribute: String): Unit
Set the name of the model attribute as which the exception should be exposed. Default is "exception". This can be either set to a different attribute name or to |
|
open fun setExceptionMappings(mappings: Properties): Unit
Set the mappings between exception class names and error view names. The exception class name can be a substring, with no wildcard support at present. A value of "ServletException" would match NB: Consider carefully how specific the pattern is, and whether to include package information (which isn't mandatory). For example, "Exception" will match nearly anything, and will probably hide other rules. "java.lang.Exception" would be correct if "Exception" was meant to define a rule for all checked exceptions. With more unusual exception names such as "BaseBusinessException" there's no need to use a FQN. |
|
open fun setExcludedExceptions(vararg excludedExceptions: Class<*>): Unit
Set one or more exceptions to be excluded from the exception mappings. Excluded exceptions are checked first and if one of them equals the actual exception, the exception will remain unresolved. |
|
open fun setStatusCodes(statusCodes: Properties): Unit
Set the HTTP status code that this exception resolver will apply for a given resolved error view. Keys are view names; values are status codes. Note that this error code will only get applied in case of a top-level request. It will not be set for an include request, since the HTTP status cannot be modified from within an include. If not specified, the default status code will be applied. |