diff --git a/org.springframework.context.support/src/main/java/org/springframework/scheduling/quartz/SpringBeanJobFactory.java b/org.springframework.context.support/src/main/java/org/springframework/scheduling/quartz/SpringBeanJobFactory.java index 9eaca4dc0e6..e03ff263011 100644 --- a/org.springframework.context.support/src/main/java/org/springframework/scheduling/quartz/SpringBeanJobFactory.java +++ b/org.springframework.context.support/src/main/java/org/springframework/scheduling/quartz/SpringBeanJobFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 the original author or authors. + * Copyright 2002-2009 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,7 +22,6 @@ import org.quartz.spi.TriggerFiredBundle; import org.springframework.beans.BeanWrapper; import org.springframework.beans.MutablePropertyValues; import org.springframework.beans.PropertyAccessorFactory; -import org.springframework.beans.BeanUtils; /** * Subclass of {@link AdaptableJobFactory} that also supports Spring-style @@ -68,8 +67,8 @@ public class SpringBeanJobFactory extends AdaptableJobFactory implements Schedul * from the scheduler context, job data map and trigger data map. */ @Override - protected Object createJobInstance(TriggerFiredBundle bundle) { - Object job = BeanUtils.instantiateClass(bundle.getJobDetail().getJobClass()); + protected Object createJobInstance(TriggerFiredBundle bundle) throws Exception { + Object job = bundle.getJobDetail().getJobClass().newInstance(); BeanWrapper bw = PropertyAccessorFactory.forBeanPropertyAccess(job); if (isEligibleForPropertyPopulation(bw.getWrappedInstance())) { MutablePropertyValues pvs = new MutablePropertyValues(); @@ -79,8 +78,7 @@ public class SpringBeanJobFactory extends AdaptableJobFactory implements Schedul pvs.addPropertyValues(bundle.getJobDetail().getJobDataMap()); pvs.addPropertyValues(bundle.getTrigger().getJobDataMap()); if (this.ignoredUnknownProperties != null) { - for (int i = 0; i < this.ignoredUnknownProperties.length; i++) { - String propName = this.ignoredUnknownProperties[i]; + for (String propName : this.ignoredUnknownProperties) { if (pvs.contains(propName) && !bw.isWritableProperty(propName)) { pvs.removePropertyValue(propName); } diff --git a/org.springframework.context/src/main/java/org/springframework/context/support/MessageSourceResourceBundle.java b/org.springframework.context/src/main/java/org/springframework/context/support/MessageSourceResourceBundle.java index 66ff4b7b61c..c5fe46acf5c 100644 --- a/org.springframework.context/src/main/java/org/springframework/context/support/MessageSourceResourceBundle.java +++ b/org.springframework.context/src/main/java/org/springframework/context/support/MessageSourceResourceBundle.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 the original author or authors. + * Copyright 2002-2009 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -84,7 +84,7 @@ public class MessageSourceResourceBundle extends ResourceBundle { * not allow for enumerating the defined message codes. */ @Override - public Enumeration getKeys() { + public Enumeration getKeys() { return null; } diff --git a/org.springframework.core/src/main/java/org/springframework/util/ObjectUtils.java b/org.springframework.core/src/main/java/org/springframework/util/ObjectUtils.java index 9442226ed1a..17f80132cd4 100644 --- a/org.springframework.core/src/main/java/org/springframework/util/ObjectUtils.java +++ b/org.springframework.core/src/main/java/org/springframework/util/ObjectUtils.java @@ -20,15 +20,18 @@ import java.lang.reflect.Array; import java.util.Arrays; /** - * Miscellaneous object utility methods. Mainly for internal use within the - * framework; consider Jakarta's Commons Lang for a more comprehensive suite - * of object utilities. + * Miscellaneous object utility methods. + * + *

Mainly for internal use within the framework; consider + * Jakarta's Commons Lang + * for a more comprehensive suite of object utilities. + * + *

Thanks to Alex Ruiz for contributing several enhancements to this class! * * @author Juergen Hoeller * @author Keith Donald * @author Rod Johnson * @author Rob Harrop - * @author Alex Ruiz * @since 19.03.2004 * @see org.apache.commons.lang.ObjectUtils */ diff --git a/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/DispatcherServlet.java b/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/DispatcherServlet.java index 8d4dc2ddcc3..7fe3a794075 100644 --- a/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/DispatcherServlet.java +++ b/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/DispatcherServlet.java @@ -269,9 +269,11 @@ public class DispatcherServlet extends FrameworkServlet { /** List of ViewResolvers used by this servlet */ private List viewResolvers; + /** - * Set whether to detect all HandlerMapping beans in this servlet's context. Else, just a single bean with name - * "handlerMapping" will be expected.

Default is "true". Turn this off if you want this servlet to use a single + * Set whether to detect all HandlerMapping beans in this servlet's context. Otherwise, + * just a single bean with name "handlerMapping" will be expected. + *

Default is "true". Turn this off if you want this servlet to use a single * HandlerMapping, despite multiple HandlerMapping beans being defined in the context. */ public void setDetectAllHandlerMappings(boolean detectAllHandlerMappings) { @@ -279,8 +281,9 @@ public class DispatcherServlet extends FrameworkServlet { } /** - * Set whether to detect all HandlerAdapter beans in this servlet's context. Else, just a single bean with name - * "handlerAdapter" will be expected.

Default is "true". Turn this off if you want this servlet to use a single + * Set whether to detect all HandlerAdapter beans in this servlet's context. Otherwise, + * just a single bean with name "handlerAdapter" will be expected. + *

Default is "true". Turn this off if you want this servlet to use a single * HandlerAdapter, despite multiple HandlerAdapter beans being defined in the context. */ public void setDetectAllHandlerAdapters(boolean detectAllHandlerAdapters) { @@ -288,18 +291,19 @@ public class DispatcherServlet extends FrameworkServlet { } /** - * Set whether to detect all HandlerExceptionResolver beans in this servlet's context. Else, just a single bean with - * name "handlerExceptionResolver" will be expected.

Default is "true". Turn this off if you want this servlet to - * use a single HandlerExceptionResolver, despite multiple HandlerExceptionResolver beans being defined in the - * context. + * Set whether to detect all HandlerExceptionResolver beans in this servlet's context. Otherwise, + * just a single bean with name "handlerExceptionResolver" will be expected. + *

Default is "true". Turn this off if you want this servlet to use a single + * HandlerExceptionResolver, despite multiple HandlerExceptionResolver beans being defined in the context. */ public void setDetectAllHandlerExceptionResolvers(boolean detectAllHandlerExceptionResolvers) { this.detectAllHandlerExceptionResolvers = detectAllHandlerExceptionResolvers; } /** - * Set whether to detect all ViewResolver beans in this servlet's context. Else, just a single bean with name - * "viewResolver" will be expected.

Default is "true". Turn this off if you want this servlet to use a single + * Set whether to detect all ViewResolver beans in this servlet's context. Otherwise, + * just a single bean with name "viewResolver" will be expected. + *

Default is "true". Turn this off if you want this servlet to use a single * ViewResolver, despite multiple ViewResolver beans being defined in the context. */ public void setDetectAllViewResolvers(boolean detectAllViewResolvers) { @@ -307,28 +311,32 @@ public class DispatcherServlet extends FrameworkServlet { } /** - * Set whether to perform cleanup of request attributes after an include request, that is, whether to reset the - * original state of all request attributes after the DispatcherServlet has processed within an include request. Else, - * just the DispatcherServlet's own request attributes will be reset, but not model attributes for JSPs or special - * attributes set by views (for example, JSTL's).

Default is "true", which is strongly recommended. Views should not - * rely on request attributes having been set by (dynamic) includes. This allows JSP views rendered by an included - * controller to use any model attributes, even with the same names as in the main JSP, without causing side effects. - * Only turn this off for special needs, for example to deliberately allow main JSPs to access attributes from JSP - * views rendered by an included controller. + * Set whether to perform cleanup of request attributes after an include request, that is, + * whether to reset the original state of all request attributes after the DispatcherServlet + * has processed within an include request. Otherwise, just the DispatcherServlet's own + * request attributes will be reset, but not model attributes for JSPs or special attributes + * set by views (for example, JSTL's). + *

Default is "true", which is strongly recommended. Views should not rely on request attributes + * having been set by (dynamic) includes. This allows JSP views rendered by an included controller + * to use any model attributes, even with the same names as in the main JSP, without causing side + * effects. Only turn this off for special needs, for example to deliberately allow main JSPs to + * access attributes from JSP views rendered by an included controller. */ public void setCleanupAfterInclude(boolean cleanupAfterInclude) { this.cleanupAfterInclude = cleanupAfterInclude; } - /** This implementation calls {@link #initStrategies}. */ + /** + * This implementation calls {@link #initStrategies}. + */ @Override protected void onRefresh(ApplicationContext context) throws BeansException { initStrategies(context); } /** - * Initialize the strategy objects that this servlet uses.

May be overridden in subclasses in order to initialize - * further strategy objects. + * Initialize the strategy objects that this servlet uses. + *

May be overridden in subclasses in order to initialize further strategy objects. */ protected void initStrategies(ApplicationContext context) { initMultipartResolver(context); @@ -342,8 +350,9 @@ public class DispatcherServlet extends FrameworkServlet { } /** - * Initialize the MultipartResolver used by this class.

If no bean is defined with the given name in the BeanFactory - * for this namespace, no multipart handling is provided. + * Initialize the MultipartResolver used by this class. + *

If no bean is defined with the given name in the BeanFactory for this namespace, + * no multipart handling is provided. */ private void initMultipartResolver(ApplicationContext context) { try { @@ -363,8 +372,9 @@ public class DispatcherServlet extends FrameworkServlet { } /** - * Initialize the LocaleResolver used by this class.

If no bean is defined with the given name in the BeanFactory - * for this namespace, we default to AcceptHeaderLocaleResolver. + * Initialize the LocaleResolver used by this class. + *

If no bean is defined with the given name in the BeanFactory for this namespace, + * we default to AcceptHeaderLocaleResolver. */ private void initLocaleResolver(ApplicationContext context) { try { @@ -384,8 +394,9 @@ public class DispatcherServlet extends FrameworkServlet { } /** - * Initialize the ThemeResolver used by this class.

If no bean is defined with the given name in the BeanFactory for - * this namespace, we default to a FixedThemeResolver. + * Initialize the ThemeResolver used by this class. + *

If no bean is defined with the given name in the BeanFactory for this namespace, + * we default to a FixedThemeResolver. */ private void initThemeResolver(ApplicationContext context) { try { @@ -406,8 +417,9 @@ public class DispatcherServlet extends FrameworkServlet { } /** - * Initialize the HandlerMappings used by this class.

If no HandlerMapping beans are defined in the BeanFactory for - * this namespace, we default to BeanNameUrlHandlerMapping. + * Initialize the HandlerMappings used by this class. + *

If no HandlerMapping beans are defined in the BeanFactory for this namespace, + * we default to BeanNameUrlHandlerMapping. */ private void initHandlerMappings(ApplicationContext context) { this.handlerMappings = null; @@ -443,8 +455,9 @@ public class DispatcherServlet extends FrameworkServlet { } /** - * Initialize the HandlerAdapters used by this class.

If no HandlerAdapter beans are defined in the BeanFactory for - * this namespace, we default to SimpleControllerHandlerAdapter. + * Initialize the HandlerAdapters used by this class. + *

If no HandlerAdapter beans are defined in the BeanFactory for this namespace, + * we default to SimpleControllerHandlerAdapter. */ private void initHandlerAdapters(ApplicationContext context) { this.handlerAdapters = null; @@ -480,8 +493,9 @@ public class DispatcherServlet extends FrameworkServlet { } /** - * Initialize the HandlerExceptionResolver used by this class.

If no bean is defined with the given name in the - * BeanFactory for this namespace, we default to no exception resolver. + * Initialize the HandlerExceptionResolver used by this class. + *

If no bean is defined with the given name in the BeanFactory for this namespace, + * we default to no exception resolver. */ private void initHandlerExceptionResolvers(ApplicationContext context) { this.handlerExceptionResolvers = null; @@ -518,8 +532,8 @@ public class DispatcherServlet extends FrameworkServlet { } /** - * Initialize the RequestToViewNameTranslator used by this servlet instance. If no implementation is configured then we - * default to DefaultRequestToViewNameTranslator. + * Initialize the RequestToViewNameTranslator used by this servlet instance. + *

If no implementation is configured then we default to DefaultRequestToViewNameTranslator. */ private void initRequestToViewNameTranslator(ApplicationContext context) { try { @@ -541,7 +555,8 @@ public class DispatcherServlet extends FrameworkServlet { } /** - * Initialize the ViewResolvers used by this class.

If no ViewResolver beans are defined in the BeanFactory for this + * Initialize the ViewResolvers used by this class. + *

If no ViewResolver beans are defined in the BeanFactory for this * namespace, we default to InternalResourceViewResolver. */ private void initViewResolvers(ApplicationContext context) { @@ -578,9 +593,9 @@ public class DispatcherServlet extends FrameworkServlet { } /** - * Return this servlet's ThemeSource, if any; else return null.

Default is to return the - * WebApplicationContext as ThemeSource, provided that it implements the ThemeSource interface. - * + * Return this servlet's ThemeSource, if any; else return null. + *

Default is to return the WebApplicationContext as ThemeSource, + * provided that it implements the ThemeSource interface. * @return the ThemeSource, if any * @see #getWebApplicationContext() */ @@ -595,18 +610,17 @@ public class DispatcherServlet extends FrameworkServlet { /** * Obtain this servlet's MultipartResolver, if any. - * - * @return the MultipartResolver used by this servlet, or null if none (indicating that no multipart - * support is available) + * @return the MultipartResolver used by this servlet, or null if none + * (indicating that no multipart support is available) */ public final MultipartResolver getMultipartResolver() { return this.multipartResolver; } /** - * Return the default strategy object for the given strategy interface.

The default implementation delegates to - * {@link #getDefaultStrategies}, expecting a single object in the list. - * + * Return the default strategy object for the given strategy interface. + *

The default implementation delegates to {@link #getDefaultStrategies}, + * expecting a single object in the list. * @param context the current WebApplicationContext * @param strategyInterface the strategy interface * @return the corresponding strategy object @@ -622,10 +636,10 @@ public class DispatcherServlet extends FrameworkServlet { } /** - * Create a List of default strategy objects for the given strategy interface.

The default implementation uses the - * "DispatcherServlet.properties" file (in the same package as the DispatcherServlet class) to determine the class - * names. It instantiates the strategy objects through the context's BeanFactory. - * + * Create a List of default strategy objects for the given strategy interface. + *

The default implementation uses the "DispatcherServlet.properties" file (in the same + * package as the DispatcherServlet class) to determine the class names. It instantiates + * the strategy objects through the context's BeanFactory. * @param context the current WebApplicationContext * @param strategyInterface the strategy interface * @return the List of corresponding strategy objects @@ -662,8 +676,8 @@ public class DispatcherServlet extends FrameworkServlet { } /** - * Create a default strategy.

The default implementation uses {@link org.springframework.beans.factory.config.AutowireCapableBeanFactory#createBean}. - * + * Create a default strategy. + *

The default implementation uses {@link org.springframework.beans.factory.config.AutowireCapableBeanFactory#createBean}. * @param context the current WebApplicationContext * @param clazz the strategy implementation class to instantiate * @return the fully configured strategy instance @@ -676,8 +690,8 @@ public class DispatcherServlet extends FrameworkServlet { } /** - * Exposes the DispatcherServlet-specific request attributes and delegates to {@link #doDispatch} for the actual - * dispatching. + * Exposes the DispatcherServlet-specific request attributes and delegates to {@link #doDispatch} + * for the actual dispatching. */ @Override protected void doService(HttpServletRequest request, HttpServletResponse response) throws Exception { @@ -720,11 +734,12 @@ public class DispatcherServlet extends FrameworkServlet { } /** - * Process the actual dispatching to the handler.

The handler will be obtained by applying the servlet's - * HandlerMappings in order. The HandlerAdapter will be obtained by querying the servlet's installed HandlerAdapters to - * find the first that supports the handler class.

All HTTP methods are handled by this method. It's up to - * HandlerAdapters or handlers themselves to decide which methods are acceptable. - * + * Process the actual dispatching to the handler. + *

The handler will be obtained by applying the servlet's HandlerMappings in order. + * The HandlerAdapter will be obtained by querying the servlet's installed HandlerAdapters + * to find the first that supports the handler class. + *

All HTTP methods are handled by this method. It's up to HandlerAdapters or handlers + * themselves to decide which methods are acceptable. * @param request current HTTP request * @param response current HTTP response * @throws Exception in case of any kind of processing failure @@ -827,8 +842,8 @@ public class DispatcherServlet extends FrameworkServlet { } /** - * Override HttpServlet's getLastModified method to evaluate the Last-Modified value of the mapped - * handler. + * Override HttpServlet's getLastModified method to evaluate the Last-Modified value + * of the mapped handler. */ @Override protected long getLastModified(HttpServletRequest request) { @@ -862,10 +877,9 @@ public class DispatcherServlet extends FrameworkServlet { } /** - * Build a LocaleContext for the given request, exposing the request's primary locale as current locale.

The default - * implementation uses the dispatcher's LocaleResolver to obtain the current locale, which might change during a - * request. - * + * Build a LocaleContext for the given request, exposing the request's primary locale as current locale. + *

The default implementation uses the dispatcher's LocaleResolver to obtain the current locale, + * which might change during a request. * @param request current HTTP request * @return the corresponding LocaleContext */ @@ -884,9 +898,8 @@ public class DispatcherServlet extends FrameworkServlet { } /** - * Convert the request into a multipart request, and make multipart resolver available. If no multipart resolver is - * set, simply use the existing request. - * + * Convert the request into a multipart request, and make multipart resolver available. + *

If no multipart resolver is set, simply use the existing request. * @param request current HTTP request * @return the processed request (multipart wrapper if necessary) * @see MultipartResolver#resolveMultipart @@ -907,7 +920,6 @@ public class DispatcherServlet extends FrameworkServlet { /** * Clean up any resources used by the given multipart request (if any). - * * @param request current HTTP request * @see MultipartResolver#cleanupMultipart */ @@ -919,7 +931,6 @@ public class DispatcherServlet extends FrameworkServlet { /** * Return the HandlerExecutionChain for this request. Try all handler mappings in order. - * * @param request current HTTP request * @param cache whether to cache the HandlerExecutionChain in a request attribute * @return the HandlerExceutionChain, or null if no handler could be found @@ -951,7 +962,6 @@ public class DispatcherServlet extends FrameworkServlet { /** * No handler found -> set appropriate HTTP response status. - * * @param request current HTTP request * @param response current HTTP response * @throws Exception if preparing the response failed @@ -967,7 +977,6 @@ public class DispatcherServlet extends FrameworkServlet { /** * Return the HandlerAdapter for this handler object. - * * @param handler the handler object to find an adapter for * @throws ServletException if no HandlerAdapter can be found for the handler. This is a fatal error. */ @@ -986,11 +995,10 @@ public class DispatcherServlet extends FrameworkServlet { /** * Determine an error ModelAndView via the registered HandlerExceptionResolvers. - * * @param request current HTTP request * @param response current HTTP response - * @param handler the executed handler, or null if none chosen at the time of the exception (for example, - * if multipart resolution failed) + * @param handler the executed handler, or null if none chosen at the time of the exception + * (for example, if multipart resolution failed) * @param ex the exception that got thrown during handler execution * @return a corresponding ModelAndView to forward to * @throws Exception if no error ModelAndView found @@ -1024,9 +1032,8 @@ public class DispatcherServlet extends FrameworkServlet { } /** - * Render the given ModelAndView. This is the last stage in handling a request. It may involve resolving the view by - * name. - * + * Render the given ModelAndView. + *

This is the last stage in handling a request. It may involve resolving the view by name. * @param mv the ModelAndView to render * @param request current HTTP servlet request * @param response current HTTP servlet response @@ -1067,7 +1074,6 @@ public class DispatcherServlet extends FrameworkServlet { /** * Translate the supplied request into a default view name. - * * @param request current HTTP servlet request * @return the view name (or null if no default found) * @throws Exception if view name translation failed @@ -1077,16 +1083,17 @@ public class DispatcherServlet extends FrameworkServlet { } /** - * Resolve the given view name into a View object (to be rendered).

Default implementations asks all ViewResolvers - * of this dispatcher. Can be overridden for custom resolution strategies, potentially based on specific model - * attributes or request parameters. - * + * Resolve the given view name into a View object (to be rendered). + *

Default implementations asks all ViewResolvers of this dispatcher. + * Can be overridden for custom resolution strategies, potentially based on + * specific model attributes or request parameters. * @param viewName the name of the view to resolve * @param model the model to be passed to the view * @param locale the current locale * @param request current HTTP servlet request * @return the View object, or null if none found - * @throws Exception if the view cannot be resolved (typically in case of problems creating an actual View object) + * @throws Exception if the view cannot be resolved + * (typically in case of problems creating an actual View object) * @see ViewResolver#resolveViewName */ protected View resolveViewName(String viewName, @@ -1104,9 +1111,9 @@ public class DispatcherServlet extends FrameworkServlet { } /** - * Trigger afterCompletion callbacks on the mapped HandlerInterceptors. Will just invoke afterCompletion for all - * interceptors whose preHandle invocation has successfully completed and returned true. - * + * Trigger afterCompletion callbacks on the mapped HandlerInterceptors. + * Will just invoke afterCompletion for all interceptors whose preHandle invocation + * has successfully completed and returned true. * @param mappedHandler the mapped HandlerExecutionChain * @param interceptorIndex index of last interceptor that successfully completed * @param ex Exception thrown on handler execution, or null if none @@ -1137,7 +1144,6 @@ public class DispatcherServlet extends FrameworkServlet { /** * Restore the request attributes after an include. - * * @param request current HTTP request * @param attributesSnapshot the snapshot of the request attributes before the include */ diff --git a/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/handler/SimpleMappingExceptionResolver.java b/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/handler/SimpleMappingExceptionResolver.java index 5538010f0df..4ca0e0cf37f 100644 --- a/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/handler/SimpleMappingExceptionResolver.java +++ b/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/handler/SimpleMappingExceptionResolver.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 the original author or authors. + * Copyright 2002-2009 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,16 +17,14 @@ package org.springframework.web.servlet.handler; import java.util.Enumeration; -import java.util.Properties; -import java.util.Map; -import java.util.Iterator; import java.util.HashMap; +import java.util.Map; +import java.util.Properties; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.springframework.web.servlet.ModelAndView; import org.springframework.web.util.WebUtils; -import org.springframework.util.CollectionUtils; /** * {@link org.springframework.web.servlet.HandlerExceptionResolver} implementation that allows for mapping exception @@ -37,8 +35,8 @@ import org.springframework.util.CollectionUtils; * * @author Juergen Hoeller * @author Arjen Poutsma - * @see org.springframework.web.servlet.DispatcherServlet * @since 22.11.2003 + * @see org.springframework.web.servlet.DispatcherServlet */ public class SimpleMappingExceptionResolver extends AbstractHandlerExceptionResolver { @@ -55,20 +53,20 @@ public class SimpleMappingExceptionResolver extends AbstractHandlerExceptionReso private String exceptionAttribute = DEFAULT_EXCEPTION_ATTRIBUTE; + /** - * 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. - * - * @param mappings exception patterns (can also be fully qualified class names) as keys, and error view names as - * values - * @see org.springframework.transaction.interceptor.RuleBasedTransactionAttribute - * @see org.springframework.transaction.interceptor.RollbackRuleAttribute + * 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. + * @param mappings exception patterns (can also be fully qualified class names) as keys, + * and error view names as values */ public void setExceptionMappings(Properties mappings) { this.exceptionMappings = mappings; @@ -85,12 +83,9 @@ public class SimpleMappingExceptionResolver extends AbstractHandlerExceptionReso /** * 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. - * * @see #setDefaultStatusCode(int) */ public void setStatusCodes(Properties statusCodes) { @@ -104,13 +99,10 @@ public class SimpleMappingExceptionResolver extends AbstractHandlerExceptionReso /** * 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). - * * @param defaultStatusCode HTTP status code value, for example 500 * ({@link HttpServletResponse#SC_INTERNAL_SERVER_ERROR}) or 404 ({@link HttpServletResponse#SC_NOT_FOUND}) * @see #setStatusCodes(Properties) @@ -122,7 +114,6 @@ public class SimpleMappingExceptionResolver extends AbstractHandlerExceptionReso /** * 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 #DEFAULT_EXCEPTION_ATTRIBUTE */ public void setExceptionAttribute(String exceptionAttribute) { @@ -134,7 +125,6 @@ public class SimpleMappingExceptionResolver extends AbstractHandlerExceptionReso * 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. - * * @param request current HTTP request * @param response current HTTP response * @param handler the executed handler, or null if none chosen at the time of the exception (for example, @@ -167,7 +157,6 @@ public class SimpleMappingExceptionResolver extends AbstractHandlerExceptionReso /** * Determine the view name for the given exception, searching the {@link #setExceptionMappings "exceptionMappings"}, * using the {@link #setDefaultErrorView "defaultErrorView"} as fallback. - * * @param ex the exception that got thrown during handler execution * @param request current HTTP request (useful for obtaining metadata) * @return the resolved view name, or null if none found @@ -191,7 +180,6 @@ public class SimpleMappingExceptionResolver extends AbstractHandlerExceptionReso /** * Find a matching view name in the given exception mappings. - * * @param exceptionMappings mappings between exception class names and error view names * @param ex the exception that got thrown during handler execution * @return the view name, or null if none found @@ -218,9 +206,9 @@ public class SimpleMappingExceptionResolver extends AbstractHandlerExceptionReso } /** - * 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 {@link - * org.springframework.transaction.interceptor.RollbackRuleAttribute}. + * 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. */ protected int getDepth(String exceptionMapping, Exception ex) { return getDepth(exceptionMapping, ex.getClass(), 0); @@ -240,17 +228,14 @@ public class SimpleMappingExceptionResolver extends AbstractHandlerExceptionReso /** * Determine the HTTP status code to apply for the given error view. - * *

The default implementation returns the status code for the given view name (specified through the * {@link #setStatusCodes(Properties) statusCodes} property), or falls back to the * {@link #setDefaultStatusCode defaultStatusCode} if there is no match. - * *

Override this in a custom subclass to customize this behavior. - * * @param request current HTTP request * @param viewName the name of the error view - * @return the HTTP status code to use, or null for the servlet container's default (200 in case of a - * standard error view) + * @return the HTTP status code to use, or null for the servlet container's default + * (200 in case of a standard error view) * @see #setDefaultStatusCode * @see #applyStatusCodeIfPossible */ @@ -262,9 +247,8 @@ public class SimpleMappingExceptionResolver extends AbstractHandlerExceptionReso } /** - * Apply the specified HTTP status code to the given response, if possible (that is, if not executing within an include - * request). - * + * Apply the specified HTTP status code to the given response, if possible (that is, + * if not executing within an include request). * @param request current HTTP request * @param response current HTTP response * @param statusCode the status code to apply @@ -283,9 +267,8 @@ public class SimpleMappingExceptionResolver extends AbstractHandlerExceptionReso } /** - * Return a ModelAndView for the given request, view name and exception.

The default implementation delegates to - * {@link #getModelAndView(String, Exception)}. - * + * Return a ModelAndView for the given request, view name and exception. + *

The default implementation delegates to {@link #getModelAndView(String, Exception)}. * @param viewName the name of the error view * @param ex the exception that got thrown during handler execution * @param request current HTTP request (useful for obtaining metadata) @@ -296,9 +279,9 @@ public class SimpleMappingExceptionResolver extends AbstractHandlerExceptionReso } /** - * Return a ModelAndView for the given view name and exception.

The default implementation adds the specified - * exception attribute. Can be overridden in subclasses. - * + * Return a ModelAndView for the given view name and exception. + *

The default implementation adds the specified exception attribute. + * Can be overridden in subclasses. * @param viewName the name of the error view * @param ex the exception that got thrown during handler execution * @return the ModelAndView instance