类 SimpleMappingExceptionResolver
- java.lang.Object
- org.springframework.web.portlet.handler.AbstractHandlerExceptionResolver
- org.springframework.web.portlet.handler.SimpleMappingExceptionResolver
- 所有已实现的接口:
Ordered
,HandlerExceptionResolver
public class SimpleMappingExceptionResolver extends AbstractHandlerExceptionResolver
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.
- 从以下版本开始:
- 2.0
- 作者:
- Juergen Hoeller, John A. Lewis, Arjen Poutsma
字段概要
字段 修饰符和类型 字段 说明 static String
DEFAULT_EXCEPTION_ATTRIBUTE
The default name of the exception attribute: "exception".从类继承的字段 org.springframework.web.portlet.handler.AbstractHandlerExceptionResolver
logger
从接口继承的字段 org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
构造器概要
构造器 构造器 说明 SimpleMappingExceptionResolver()
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 protected String
determineViewName(Exception ex, PortletRequest request)
Determine the view name for the given exception, searching the"exceptionMappings"
, using the"defaultErrorView"
as fallback.protected ModelAndView
doResolveException(PortletRequest request, MimeResponse 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 mappingsprotected int
getDepth(String exceptionMapping, Exception ex)
Return the depth to the superclass matching.protected ModelAndView
getModelAndView(String viewName, Exception ex)
Return a ModelAndView for the given view name and exception.protected ModelAndView
getModelAndView(String viewName, Exception ex, PortletRequest request)
Return a ModelAndView for the given request, view name and exception.void
setDefaultErrorView(String defaultErrorView)
Set the name of the default error view.void
setExceptionAttribute(String exceptionAttribute)
Set the name of the model attribute as which the exception should be exposed.void
setExceptionMappings(Properties mappings)
Set the mappings between exception class names and error view names.从类继承的方法 org.springframework.web.portlet.handler.AbstractHandlerExceptionResolver
buildLogMessage, getOrder, logException, resolveException, resolveException, setMappedHandlerClasses, setMappedHandlers, setOrder, setRenderWhenMinimized, setWarnLogCategory, shouldApplyTo
字段详细资料
DEFAULT_EXCEPTION_ATTRIBUTE
public static final String DEFAULT_EXCEPTION_ATTRIBUTE
The default name of the exception attribute: "exception".- 另请参阅:
- 常量字段值
构造器详细资料
SimpleMappingExceptionResolver
public SimpleMappingExceptionResolver()
方法详细资料
setExceptionMappings
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. A value of "PortletException" would matchjavax.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.
- 参数:
mappings
- exception patterns (can also be fully qualified class names) as keys, and error view names as values- 另请参阅:
RuleBasedTransactionAttribute
,RollbackRuleAttribute
setDefaultErrorView
public void setDefaultErrorView(String defaultErrorView)
Set the name of the default error view. This view will be returned if no specific mapping was found.Default is none.
setExceptionAttribute
public void setExceptionAttribute(String exceptionAttribute)
Set the name of the model attribute as which the exception should be exposed. Default is "exception".
doResolveException
protected ModelAndView doResolveException(PortletRequest request, MimeResponse 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.- 指定者:
doResolveException
在类中AbstractHandlerExceptionResolver
- 参数:
request
- current portlet requestresponse
- current portlet responsehandler
- the executed handler, or null if none chosen at the time of the exception (for example, if multipart resolution failed)ex
- the exception that got thrown during handler execution- 返回:
- a corresponding ModelAndView to forward to, or null for default processing
determineViewName
protected String determineViewName(Exception ex, PortletRequest request)
Determine the view name for the given exception, searching the"exceptionMappings"
, using the"defaultErrorView"
as fallback.- 参数:
ex
- the exception that got thrown during handler executionrequest
- current portlet request (useful for obtaining metadata)- 返回:
- the resolved view name, or
null
if none found
findMatchingViewName
protected String findMatchingViewName(Properties exceptionMappings, Exception ex)
Find a matching view name in the given exception mappings- 参数:
exceptionMappings
- mappings between exception class names and error view namesex
- the exception that got thrown during handler execution- 返回:
- the view name, or
null
if none found - 另请参阅:
setExceptionMappings(java.util.Properties)
getDepth
protected int getDepth(String exceptionMapping, Exception ex)
Return the depth to the superclass matching.0 means ex matches exactly. Returns -1 if there's no match. Otherwise, returns depth. Lowest depth wins.
Follows the same algorithm as
RollbackRuleAttribute
.
getModelAndView
protected ModelAndView getModelAndView(String viewName, Exception ex, PortletRequest request)
Return a ModelAndView for the given request, view name and exception. Default implementation delegates togetModelAndView(viewName, ex)
.- 参数:
viewName
- the name of the error viewex
- the exception that got thrown during handler executionrequest
- current portlet request (useful for obtaining metadata)- 返回:
- the ModelAndView instance
- 另请参阅:
getModelAndView(String, Exception)
getModelAndView
protected ModelAndView getModelAndView(String viewName, Exception ex)
Return a ModelAndView for the given view name and exception. Default implementation adds the specified exception attribute. Can be overridden in subclasses.- 参数:
viewName
- the name of the error viewex
- the exception that got thrown during handler execution- 返回:
- the ModelAndView instance
- 另请参阅:
setExceptionAttribute(java.lang.String)