|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT |
@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:
ServletRequest
/ HttpServletRequest
or PortletRequest
/ ActionRequest
/
RenderRequest
. Note that in the Portlet case,
an explicitly declared action/render argument is also used for mapping
specific request types onto a handler method (in case of no other
information given that differentiates between action and render requests).
HttpSession
or PortletSession
.
An argument of this type will enforce the presence of a corresponding session.
As a consequence, such an argument will never be 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.
WebRequest
or
NativeWebRequest
.
Allows for generic request parameter access as well as request/session
attribute access, without ties to the native Servlet/Portlet API.
Locale
for the current request locale
(determined by the most specific locale resolver available,
i.e. the configured LocaleResolver
in a Servlet environment and the portal locale in a Portlet environment).
InputStream
/ Reader
for access
to the request's content. This will be the raw InputStream/Reader as
exposed by the Servlet/Portlet API.
OutputStream
/ Writer
for generating
the response's content. This will be the raw OutputStream/Writer as
exposed by the Servlet/Portlet API.
The following return types are supported for handler methods:
ModelAndView
object (Servlet MVC or Portlet MVC).
Model
object, with the view name
implicitly determined through a RequestToViewNameTranslator
.
Map
object for exposing a model,
with the view name implicitly determined through a
RequestToViewNameTranslator
.
View
object.
String
value which is interpreted as view name.
void
if the method handles the response itself (by
writing the response content directly, declaring an argument of type
ServletResponse
/ HttpServletResponse
/ RenderResponse
for that purpose)
or if the view name is supposed to be implicitly determined through a
RequestToViewNameTranslator
(not declaring a response argument in the handler method signature;
only applicable in a Servlet environment).
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
.
WebRequest
,
AnnotationMethodHandlerExceptionResolver
Optional Element Summary | |
---|---|
Class<? extends Throwable>[] |
value
Exceptions handled by the annotation method. |
public abstract Class<? extends Throwable>[] value
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT |