| java.lang.Object org.springframework.web.portlet.handler.SimpleMappingExceptionResolver
SimpleMappingExceptionResolver | public class SimpleMappingExceptionResolver implements HandlerExceptionResolver,Ordered(Code) | | org.springframework.web.portlet.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 DispatcherPortlet.
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: John A. Lewis since: 2.0 |
Method Summary | |
protected String | buildLogMessage(Exception ex, RenderRequest request) Build a log message for the given exception, occured during processing
the given request. | protected String | determineViewName(Exception ex, RenderRequest request) Determine the view name for the given exception, searching the
SimpleMappingExceptionResolver.setExceptionMappings "exceptionMappings" , using the
SimpleMappingExceptionResolver.setDefaultErrorView "defaultErrorView" as fallback. | protected ModelAndView | doResolveException(RenderRequest request, RenderResponse 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) | 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, RenderRequest 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, RenderRequest 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(RenderRequest request, RenderResponse 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 | 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 map.
The exception mappings and the default error view will only apply
to the specified handlers.
If no handlers set, both the exception mappings and the default error
view will apply to all handlers. | public void | setOrder(int order) | public void | setRenderWhenMinimized(boolean renderWhenMinimized) Set if the resolver should render a view when the portlet is in
a minimized window. | public void | setWarnLogCategory(String loggerName) Set the log category for warn logging. | protected boolean | shouldApplyTo(RenderRequest 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, RenderRequest 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 portlet request (useful for obtaining metadata) the log message to use |
doResolveException | protected ModelAndView doResolveException(RenderRequest request, RenderResponse 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.
Parameters: request - current portlet request Parameters: response - current portlet response Parameters: handler - the executed handler, or null if none chosen at the time ofthe 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, RenderRequest request)(Code) | | Return a ModelAndView for the given request, view name and exception.
Default implementation delegates to getModelAndView(viewName, ex) .
Parameters: viewName - the name of the error view Parameters: ex - the exception that got thrown during handler execution Parameters: request - current portlet request (useful for obtaining metadata) the ModelAndView instance See Also: SimpleMappingExceptionResolver.getModelAndView(String,Exception) |
getModelAndView | protected ModelAndView getModelAndView(String viewName, Exception ex)(Code) | | Return a ModelAndView for the given view name and exception.
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.
|
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 "PortletException" would match
javax.portet.PortletException 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 map.
The exception mappings and the default error view will only apply
to the specified handlers.
If no handlers set, both 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) | | |
setRenderWhenMinimized | public void setRenderWhenMinimized(boolean renderWhenMinimized)(Code) | | Set if the resolver should render a view when the portlet is in
a minimized window. The default is "false".
See Also: javax.portlet.RenderRequest.getWindowState See Also: javax.portlet.WindowState.MINIMIZED |
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(RenderRequest 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, and alspo checks the window state (according
to the "renderWhenMinimize" property).
Parameters: request - current portlet 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 |
|
|