@Target([AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER]) class ExceptionHandler
Annotation for handling exceptions in specific handler classes and/or handler methods.
Handler methods which are annotated with this annotation are allowed to have very flexible signatures. They may have parameters of the following types, in arbitrary order:
#value(). null. Note that session access may not be thread-safe, in particular in a Servlet environment: Consider switching the "synchronizeOnSession" flag to "true" if multiple requests are allowed to access a session concurrently. The following return types are supported for handler methods:
ModelAndView object (from Servlet MVC). void if the method handles the response itself (by writing the response content directly, declaring an argument of type javax.servlet.ServletResponse / javax.servlet.http.HttpServletResponse for that purpose) or if the view name is supposed to be implicitly determined through a org.springframework.web.servlet.RequestToViewNameTranslator (not declaring a response argument in the handler method signature). In Servlet environments, you can combine the ExceptionHandler annotation with ResponseStatus, to define the response status for the HTTP response.
Author
Arjen Poutsma
Author
Juergen Hoeller
Since
3.0
See Also
org.springframework.web.context.request.WebRequest
ExceptionHandler(vararg value: KClass<out Throwable>)
Annotation for handling exceptions in specific handler classes and/or handler methods. Handler methods which are annotated with this annotation are allowed to have very flexible signatures. They may have parameters of the following types, in arbitrary order:
The following return types are supported for handler methods:
In Servlet environments, you can combine the |
val value: Array<KClass<out Throwable>>
Exceptions handled by the annotated method. If empty, will default to any exceptions listed in the method argument list. |