public interface HandlerAdapter
Interface that must be implemented for each handler type to handle a request.
This interface is used to allow the DispatcherServlet
to be indefinitely
extensible. The DispatcherServlet accesses all installed handlers through this
interface, meaning that it does not contain code specific to any handler type.
Note that a handler can be of type Object
. This is to enable
handlers from other frameworks to be integrated with this framework without
custom coding, as well as to allow for annotation handler objects that do
not obey any specific Java interface.
This interface is not intended for application developers. It is available to handlers who want to develop their own web workflow.
Note: HandlerAdaptger implementators may implement the
Ordered
interface to be able to specify a
sorting order (and thus a priority) for getting applied by DispatcherServlet.
Non-Ordered instances get treated as lowest priority.
SimpleControllerHandlerAdapter
,
SimpleServletHandlerAdapter
Modifier and Type | Method and Description |
---|---|
long |
getLastModified(HttpServletRequest request,
Object handler)
Same contract as for HttpServlet's
getLastModified method. |
ModelAndView |
handle(HttpServletRequest request,
HttpServletResponse response,
Object handler)
Use the given handler to handle this request.
|
boolean |
supports(Object handler)
Given a handler instance, return whether or not this HandlerAdapter can
support it.
|
boolean supports(Object handler)
A typical implementation:
return (handler instanceof MyHandler);
handler
- handler object to checkModelAndView handle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception
request
- current HTTP requestresponse
- current HTTP responsehandler
- handler to use. This object must have previously been passed
to the supports
method of this interface, which must have
returned true
.null
if the request has been handled directlyException
- in case of errorslong getLastModified(HttpServletRequest request, Object handler)
getLastModified
method.
Can simply return -1 if there's no support in the handler class.request
- current HTTP requesthandler
- handler to useHttpServlet.getLastModified(javax.servlet.http.HttpServletRequest)
,
LastModified.getLastModified(javax.servlet.http.HttpServletRequest)