Annotation Type ExceptionHandler

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: @RequestMapping will only be processed if a corresponding HandlerMapping (for type level annotations) and/or HandlerAdapter (for method level annotations) is present in the dispatcher. This is the case by default in both DispatcherServlet and DispatcherPortlet. However, if you are defining custom HandlerMappings or HandlerAdapters, then you need to make sure that a corresponding custom DefaultAnnotationHandlerMapping and/or AnnotationMethodHandlerAdapter is defined as well - provided that you intend to use @RequestMapping.

Arjen Poutsma
See Also:
WebRequest, AnnotationMethodHandlerExceptionResolver

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


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.