diff --git a/spring-framework-reference/src/mvc.xml b/spring-framework-reference/src/mvc.xml index 8ff7c2cf9ad..f320f099ea7 100644 --- a/spring-framework-reference/src/mvc.xml +++ b/spring-framework-reference/src/mvc.xml @@ -2809,6 +2809,49 @@ public class FileUploadBean { exception mapping feature from the Servlet API, but it's also possible to implement more finely grained mappings of exceptions from different handlers. + +
+ <interfacename>@ExceptionResolver</interfacename> + + As an alternative to implementing the HandlerExceptionResolver, you + can use the @ExceptionHandler. The @ExceptionHandler method annotation is + used within a controller to specify which method will be invoked when an + exception of a specific type is thrown during the execution of + controller methods. For example + + @Controller +public class SimpleController { + + // other controller method omitted + + @ExceptionHandler(IOException.class) + public String handleIOException(IOException ex, HttpServletRequest request) { + return ClassUtils.getShortName(ex.getClass()); + } +} + + will invoke the 'handlerIOException' method when a + java.io.IOException is thrown. + + The @ExceptionHandler value can be set to + an array of Exception types. If an exception is thrown matches one of + the types in the list, then the method annotated with the matching + @ExceptionHandler will be invoked. If the + annotation value is not set then the exception types listed as method + arguments are used. + + Much like standard controller methods annotated with a + @RequestMapping annotation, the method arguments + and return values of @ExceptionHandler methods + are very flexible. For example, the + HttpServletRequest can be accessed in Servlet + environments and the PortletRequest in Portlet + environments. The return type can be a String, + which is interpreted as a view name or a + ModelAndView object. Please refer to the API + documentation for more details. +
+
diff --git a/spring-framework-reference/src/rest.xml b/spring-framework-reference/src/rest.xml index 9edd32c4524..1244979da6c 100644 --- a/spring-framework-reference/src/rest.xml +++ b/spring-framework-reference/src/rest.xml @@ -122,45 +122,5 @@ public String deletePet(@PathVariable int ownerId, @PathVariable int petId) { or an AspectJ aspect.
-
- Exception Handling - - The @ExceptionHandler method annotation is - used within a controller to specify which method will be invoked when an - exception of a specific type is thrown during the execution of - controller methods. For example - - @Controller -public class SimpleController { - - // other controller method omitted - - @ExceptionHandler(IOException.class) - public String handleIOException(IOException ex, HttpServletRequest request) { - return ClassUtils.getShortName(ex.getClass()); - } -} - - will invoke the 'handlerIOException' method when a - java.io.IOException is thrown. - - The @ExceptionHandler value can be set to - an array of Exception types. If an exception is thrown matches one of - the types in the list, then the method annotated with the matching - @ExceptionHandler will be invoked. If the - annotation value is not set then the exception types listed as method - arguments are used. - - Much like standard controller methods annotated with a - @RequestMapping annotation, the method arguments - and return values of @ExceptionHandler methods - are very flexible. For example, the - HttpServletRequest can be accessed in Servlet - environments and the PortletRequest in Portlet - environments. The return type can be a String, - which is interpreted as a view name or a - ModelAndView object. Please refer to the API - documentation for more details. -