30
30
/**
31
31
* Abstract base class for {@link HandlerExceptionResolver} implementations.
32
32
*
33
- * <p>Provides a set of mapped handlers that the resolver should map to,
34
- * and the {@link Ordered} implementation.
33
+ * <p>Supports mapped {@linkplain #setMappedHandlers handlers} and
34
+ * {@linkplain #setMappedHandlerClasses handler classes} that the resolver
35
+ * should be applied to and implements the {@link Ordered} interface.
35
36
*
36
37
* @author Arjen Poutsma
37
38
* @author Juergen Hoeller
39
+ * @author Sam Brannen
38
40
* @since 3.0
39
41
*/
40
42
public abstract class AbstractHandlerExceptionResolver implements HandlerExceptionResolver , Ordered {
@@ -67,10 +69,10 @@ public int getOrder() {
67
69
68
70
/**
69
71
* Specify the set of handlers that this exception resolver should apply to.
70
- * The exception mappings and the default error view will only apply to the specified handlers.
71
- * <p>If no handlers and handler classes are set, the exception mappings and the default error
72
+ * <p> The exception mappings and the default error view will only apply to the specified handlers.
73
+ * <p>If no handlers or handler classes are set, the exception mappings and the default error
72
74
* view will apply to all handlers. This means that a specified default error view will be used
73
- * as fallback for all exceptions; any further HandlerExceptionResolvers in the chain will be
75
+ * as a fallback for all exceptions; any further HandlerExceptionResolvers in the chain will be
74
76
* ignored in this case.
75
77
*/
76
78
public void setMappedHandlers (Set <?> mappedHandlers ) {
@@ -79,11 +81,11 @@ public void setMappedHandlers(Set<?> mappedHandlers) {
79
81
80
82
/**
81
83
* Specify the set of classes that this exception resolver should apply to.
82
- * The exception mappings and the default error view will only apply to handlers of the
83
- * specified type ; the specified types may be interfaces and superclasses of handlers as well.
84
- * <p>If no handlers and handler classes are set, the exception mappings and the default error
84
+ * <p> The exception mappings and the default error view will only apply to handlers of the
85
+ * specified types ; the specified types may be interfaces or superclasses of handlers as well.
86
+ * <p>If no handlers or handler classes are set, the exception mappings and the default error
85
87
* view will apply to all handlers. This means that a specified default error view will be used
86
- * as fallback for all exceptions; any further HandlerExceptionResolvers in the chain will be
88
+ * as a fallback for all exceptions; any further HandlerExceptionResolvers in the chain will be
87
89
* ignored in this case.
88
90
*/
89
91
public void setMappedHandlerClasses (Class <?>[] mappedHandlerClasses ) {
@@ -92,11 +94,11 @@ public void setMappedHandlerClasses(Class<?>[] mappedHandlerClasses) {
92
94
93
95
/**
94
96
* Set the log category for warn logging. The name will be passed to the underlying logger
95
- * implementation through Commons Logging, getting interpreted as log category according
97
+ * implementation through Commons Logging, getting interpreted as a log category according
96
98
* to the logger's configuration.
97
99
* <p>Default is warn logging using the {@link AbstractHandlerExceptionResolver} class name derived logger.
98
- * Set to {@code null} to disable warn logging.
99
- * Override the {@link #logException} method for custom logging.
100
+ * <p> Set to {@code null} to disable warn logging.
101
+ * <p> Override the {@link #logException} method for custom logging.
100
102
* @see org.apache.commons.logging.LogFactory#getLog(String)
101
103
* @see org.apache.log4j.Logger#getLogger(String)
102
104
* @see java.util.logging.Logger#getLogger(String)
@@ -107,19 +109,19 @@ public void setWarnLogCategory(String loggerName) {
107
109
108
110
/**
109
111
* Specify whether to prevent HTTP response caching for any view resolved
110
- * by this HandlerExceptionResolver .
111
- * <p>Default is " false" . Switch this to " true" in order to automatically
112
- * generate HTTP response headers that suppress response caching.
112
+ * by this exception resolver .
113
+ * <p>Default is {@code false} . Switch this to {@code true} in order to
114
+ * automatically generate HTTP response headers that suppress response caching.
113
115
*/
114
116
public void setPreventResponseCaching (boolean preventResponseCaching ) {
115
117
this .preventResponseCaching = preventResponseCaching ;
116
118
}
117
119
118
-
119
120
/**
120
- * Checks whether this resolver is supposed to apply (i.e. the handler matches
121
- * in case of "mappedHandlers" having been specified), then delegates to the
122
- * {@link #doResolveException} template method.
121
+ * Check whether this resolver is supposed to apply (i.e. if the supplied handler
122
+ * matches any of the configured {@linkplain #setMappedHandlers handlers} or
123
+ * {@linkplain #setMappedHandlerClasses handler classes}), and then delegate
124
+ * to the {@link #doResolveException} template method.
123
125
*/
124
126
@ Override
125
127
public ModelAndView resolveException (HttpServletRequest request , HttpServletResponse response ,
@@ -145,8 +147,9 @@ public ModelAndView resolveException(HttpServletRequest request, HttpServletResp
145
147
146
148
/**
147
149
* Check whether this resolver is supposed to apply to the given handler.
148
- * <p>The default implementation checks against the specified mapped handlers
149
- * and handler classes, if any.
150
+ * <p>The default implementation checks against the configured
151
+ * {@linkplain #setMappedHandlers handlers} and
152
+ * {@linkplain #setMappedHandlerClasses handler classes}, if any.
150
153
* @param request current HTTP request
151
154
* @param handler the executed handler, or {@code null} if none chosen
152
155
* at the time of the exception (for example, if multipart resolution failed)
@@ -222,10 +225,9 @@ protected void preventCaching(HttpServletResponse response) {
222
225
response .addHeader (HEADER_CACHE_CONTROL , "no-store" );
223
226
}
224
227
225
-
226
228
/**
227
- * Actually resolve the given exception that got thrown during on handler execution,
228
- * returning a ModelAndView that represents a specific error page if appropriate.
229
+ * Actually resolve the given exception that got thrown during handler execution,
230
+ * returning a {@link ModelAndView} that represents a specific error page if appropriate.
229
231
* <p>May be overridden in subclasses, in order to apply specific exception checks.
230
232
* Note that this template method will be invoked <i>after</i> checking whether this
231
233
* resolved applies ("mappedHandlers" etc), so an implementation may simply proceed
@@ -235,7 +237,7 @@ protected void preventCaching(HttpServletResponse response) {
235
237
* @param handler the executed handler, or {@code null} if none chosen at the time
236
238
* of the exception (for example, if multipart resolution failed)
237
239
* @param ex the exception that got thrown during handler execution
238
- * @return a corresponding ModelAndView to forward to, or {@code null} for default processing
240
+ * @return a corresponding {@code ModelAndView} to forward to, or {@code null} for default processing
239
241
*/
240
242
protected abstract ModelAndView doResolveException (HttpServletRequest request ,
241
243
HttpServletResponse response , Object handler , Exception ex );
0 commit comments