| java.lang.Object org.springframework.web.servlet.handler.SimpleMappingExceptionResolver
Method Summary | |
protected void | applyStatusCodeIfPossible(HttpServletRequest request, 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). | protected String | buildLogMessage(Exception ex, HttpServletRequest request) Build a log message for the given exception, occured during processing
the given request. | protected Integer | determineStatusCode(HttpServletRequest request, String viewName) Determine the HTTP status code to apply for the given error view.
The default implementation always returns the specified
SimpleMappingExceptionResolver.setDefaultStatusCode "defaultStatusCode" , as a common
status code for all error views. | protected String | determineViewName(Exception ex, HttpServletRequest request) Determine the view name for the given exception, searching the
SimpleMappingExceptionResolver.setExceptionMappings "exceptionMappings" , using the
SimpleMappingExceptionResolver.setDefaultErrorView "defaultErrorView" as fallback. | 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 String | findMatchingViewName(Properties exceptionMappings, Exception ex) Find a matching view name in the given exception mappings. | protected int | getDepth(String exceptionMapping, Exception ex) Return the depth to the superclass matching.
0 means ex matches exactly. | protected ModelAndView | getModelAndView(String viewName, Exception ex, HttpServletRequest request) Return a ModelAndView for the given request, view name and exception. | protected ModelAndView | getModelAndView(String viewName, Exception ex) Return a ModelAndView for the given view name and exception. | public int | getOrder() | protected void | logException(Exception ex, HttpServletRequest request) Log the given exception at warn level, provided that warn logging has been
activated through the
SimpleMappingExceptionResolver.setWarnLogCategory "warnLogCategory" property.
Calls
SimpleMappingExceptionResolver.buildLogMessage in order to determine the concrete message
to log. | public ModelAndView | resolveException(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) Checks whether this resolver is supposed to apply (i.e. | public void | setDefaultErrorView(String defaultErrorView) Set the name of the default error view. | public void | setDefaultStatusCode(int defaultStatusCode) Set the default HTTP status code that this exception resolver will apply
if it resolves an error view.
Note that this error code will only get applied in case of a top-level
request. | public void | setExceptionAttribute(String exceptionAttribute) Set the name of the model attribute as which the exception should
be exposed. | public void | setExceptionMappings(Properties mappings) 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. | public void | setMappedHandlerClasses(Class[] mappedHandlerClasses) Specify the set of classes that this exception resolver should apply to.
The exception mappings and the default error view will only apply
to handlers of the specified type; the specified types may be interfaces
and superclasses of handlers as well.
If no handlers and handler classes are set, the exception mappings
and the default error view will apply to all handlers. | public void | setMappedHandlers(Set mappedHandlers) Specify the set of handlers that this exception resolver should apply to.
The exception mappings and the default error view will only apply
to the specified handlers.
If no handlers and handler classes are set, the exception mappings
and the default error view will apply to all handlers. | public void | setOrder(int order) | public void | setWarnLogCategory(String loggerName) Set the log category for warn logging. | protected boolean | shouldApplyTo(HttpServletRequest request, Object handler) Check whether this resolver is supposed to apply to the given handler. |
DEFAULT_EXCEPTION_ATTRIBUTE | final public static String DEFAULT_EXCEPTION_ATTRIBUTE(Code) | | The default name of the exception attribute: "exception".
|
logger | final protected Log logger(Code) | | Logger available to subclasses
|
buildLogMessage | protected String buildLogMessage(Exception ex, HttpServletRequest request)(Code) | | Build a log message for the given exception, occured during processing
the given request.
Parameters: ex - the exception that got thrown during handler execution Parameters: request - current HTTP request (useful for obtaining metadata) the log message to use |
doResolveException | protected ModelAndView doResolveException(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex)(Code) | | 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 Parameters: response - current HTTP response Parameters: handler - the executed handler, or null if none chosen at thetime of the exception (for example, if multipart resolution failed) Parameters: ex - the exception that got thrown during handler execution a corresponding ModelAndView to forward to, or null for default processing |
findMatchingViewName | protected String findMatchingViewName(Properties exceptionMappings, Exception ex)(Code) | | Find a matching view name in the given exception mappings.
Parameters: exceptionMappings - mappings between exception class names and error view names Parameters: ex - the exception that got thrown during handler execution the view name, or null if none found See Also: SimpleMappingExceptionResolver.setExceptionMappings |
getModelAndView | protected ModelAndView getModelAndView(String viewName, Exception ex)(Code) | | Return a ModelAndView for the given view name and exception.
The default implementation adds the specified exception attribute.
Can be overridden in subclasses.
Parameters: viewName - the name of the error view Parameters: ex - the exception that got thrown during handler execution the ModelAndView instance See Also: SimpleMappingExceptionResolver.setExceptionAttribute |
getOrder | public int getOrder()(Code) | | |
setDefaultErrorView | public void setDefaultErrorView(String defaultErrorView)(Code) | | Set the name of the default error view.
This view will be returned if no specific mapping was found.
Default is none.
|
setDefaultStatusCode | public void setDefaultStatusCode(int defaultStatusCode)(Code) | | Set the default HTTP status code that this exception resolver will apply
if it resolves an error view.
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).
Parameters: defaultStatusCode - HTTP status code value, for example500 (SC_INTERNAL_SERVER_ERROR) or 404 (SC_NOT_FOUND) See Also: javax.servlet.http.HttpServletResponse.SC_INTERNAL_SERVER_ERROR See Also: javax.servlet.http.HttpServletResponse.SC_NOT_FOUND |
setExceptionAttribute | public void setExceptionAttribute(String exceptionAttribute)(Code) | | 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
null for not exposing an exception attribute at all.
See Also: SimpleMappingExceptionResolver.DEFAULT_EXCEPTION_ATTRIBUTE |
setExceptionMappings | public void setExceptionMappings(Properties mappings)(Code) | | 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
javax.servlet.ServletException and subclasses, for example.
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.
Follows the same matching algorithm as RuleBasedTransactionAttribute
and RollbackRuleAttribute.
Parameters: mappings - exception patterns (can also be fully qualified class names)as keys, and error view names as values See Also: org.springframework.transaction.interceptor.RuleBasedTransactionAttribute See Also: org.springframework.transaction.interceptor.RollbackRuleAttribute |
setMappedHandlerClasses | public void setMappedHandlerClasses(Class[] mappedHandlerClasses)(Code) | | Specify the set of classes that this exception resolver should apply to.
The exception mappings and the default error view will only apply
to handlers of the specified type; the specified types may be interfaces
and superclasses of handlers as well.
If no handlers and handler classes are set, the exception mappings
and the default error view will apply to all handlers. This means that
a specified default error view will be used as fallback for all exceptions;
any further HandlerExceptionResolvers in the chain will be ignored in
this case.
|
setMappedHandlers | public void setMappedHandlers(Set mappedHandlers)(Code) | | Specify the set of handlers that this exception resolver should apply to.
The exception mappings and the default error view will only apply
to the specified handlers.
If no handlers and handler classes are set, the exception mappings
and the default error view will apply to all handlers. This means that
a specified default error view will be used as fallback for all exceptions;
any further HandlerExceptionResolvers in the chain will be ignored in
this case.
|
setOrder | public void setOrder(int order)(Code) | | |
setWarnLogCategory | public void setWarnLogCategory(String loggerName)(Code) | | Set the log category for warn logging. The name will be passed to the
underlying logger implementation through Commons Logging, getting
interpreted as log category according to the logger's configuration.
Default is no warn logging. Specify this setting to activate
warn logging into a specific category. Alternatively, override
the
SimpleMappingExceptionResolver.logException method for custom logging.
See Also: org.apache.commons.logging.LogFactory.getLog(String) See Also: org.apache.log4j.Logger.getLogger(String) See Also: java.util.logging.Logger.getLogger(String) |
shouldApplyTo | protected boolean shouldApplyTo(HttpServletRequest request, Object handler)(Code) | | Check whether this resolver is supposed to apply to the given handler.
The default implementation checks against the specified mapped handlers
and handler classes, if any.
Parameters: request - current HTTP request Parameters: handler - the executed handler, or null if none chosen at thetime of the exception (for example, if multipart resolution failed) whether this resolved should proceed with resolving the exceptionfor the given request and handler See Also: SimpleMappingExceptionResolver.setMappedHandlers See Also: SimpleMappingExceptionResolver.setMappedHandlerClasses |
|
|