org.springframework.web.bind.annotation
Annotation Type ExceptionHandler


@Target(value=METHOD)
@Retention(value=RUNTIME)
@Documented
public @interface ExceptionHandler

Annotation for handling exceptions in specific handler classes and/or handler methods. Provides consistent style between Servlet and Portlet environments, with the semantics adapting to the concrete environment.

Handler methods which are annotated with this annotation are allowed to have very flexible signatures. They may have arguments of the following types, in arbitrary order:

The following return types are supported for handler methods:

In Servlet environments, you can combine the ExceptionHandler annotation with @ResponseStatus, to define the response status for the HTTP response.

Note: In Portlet environments, ExceptionHandler annotated methods will only be called during the render and resource phases - just like HandlerExceptionResolver beans would. Exceptions carried over from the action and event phases will be invoked during the render phase as well, with exception handler methods having to be present on the controller class that defines the applicable render method.

Since:
3.0
Author:
Arjen Poutsma, Juergen Hoeller
See Also:
WebRequest, AnnotationMethodHandlerExceptionResolver, AnnotationMethodHandlerExceptionResolver

Optional Element Summary
 Class<? extends Throwable>[] value
          Exceptions handled by the annotation method.
 

value

public abstract Class<? extends Throwable>[] value
Exceptions handled by the annotation method. If empty, will default to any exceptions listed in the method argument list.

Default:
{}