Add support for global @ExceptionHandler methods

Before this change @ExceptionHandler methods could be located in and
apply locally within a controller. The change makes it possible to have
such methods applicable globally regardless of the controller that
raised the exception.

The easiest way to do that is to add them to a class annotated with
`@ExceptionResolver`, a new annotation that is also an `@Component`
annotation (and therefore works with component scanning). It is also
possible to register classes containing `@ExceptionHandler` methods
directly with the ExceptionHandlerExceptionResolver.

When multiple `@ExceptionResolver` classes are detected, or registered
directly, the order in which they're used depends on the the `@Order`
annotation (if present) or on the value of the order field (if the
Ordered interface is implemented).

Issue: SPR-9112
This commit is contained in:
Rossen Stoyanchev
2012-06-11 14:34:44 -04:00
parent ccd2da37ce
commit c846198e46
6 changed files with 334 additions and 74 deletions

View File

@@ -18,6 +18,8 @@ Changes in version 3.2 M2 (2012-08-xx)
* added support for the HTTP PATCH method to Spring MVC and to RestTemplate (SPR-7985)
* enable smart suffix pattern match in @RequestMapping methods (SPR-7632)
* DispatcherPortlet does not forward event exceptions to the render phase by default (SPR-9287)
* add defaultCharset property to StringHttpMessageConverter
* add @ExceptionResolver annotation to detect classes with @ExceptionHandler methods
Changes in version 3.2 M1 (2012-05-28)