接口 HandlerAdapter
public interface HandlerAdapter
Portlet MVC framework SPI interface, allowing parameterization of core MVC workflow.Interface that must be implemented for each handler type to handle a request. This interface is used to allow the DispatcherPortlet to be indefinitely extensible. The DispatcherPortlet 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.
This interface is not intended for application developers. It is available to handlers who want to develop their own web workflow.
Note: Implementations can implement the Ordered interface to be able to specify a sorting order and thus a priority for getting applied by DispatcherPortlet. Non-Ordered instances get treated as lowest priority.
- 从以下版本开始:
- 2.0
- 作者:
- John A. Lewis
- 另请参阅:
SimpleControllerHandlerAdapter
方法概要
所有方法 实例方法 抽象方法 修饰符和类型 方法 说明 voidhandleAction(ActionRequest request, ActionResponse response, Object handler)Use the given handler to handle this action request.voidhandleEvent(EventRequest request, EventResponse response, Object handler)Use the given handler to handle this event request.ModelAndViewhandleRender(RenderRequest request, RenderResponse response, Object handler)Use the given handler to handle this render request.ModelAndViewhandleResource(ResourceRequest request, ResourceResponse response, Object handler)Use the given handler to handle this resource request.booleansupports(Object handler)Given a handler instance, return whether or not this HandlerAdapter can support it.
方法详细资料
supports
boolean supports(Object handler)
Given a handler instance, return whether or not this HandlerAdapter can support it. Typical HandlerAdapters will base the decision on the handler type. HandlerAdapters will usually only support one handler type each.A typical implementation:
return (handler instanceof MyHandler);- 参数:
handler- handler object to check- 返回:
- whether or not this object can use the given handler
handleAction
void handleAction(ActionRequest request, ActionResponse response, Object handler) throws Exception
Use the given handler to handle this action request. The workflow that is required may vary widely.- 参数:
request- current action requestresponse- current action responsehandler- handler to use. This object must have previously been passed to thesupportsmethod of this interface, which must have returned true.- 抛出:
Exception- in case of errors- 另请参阅:
Portlet.processAction(javax.portlet.ActionRequest, javax.portlet.ActionResponse)
handleRender
ModelAndView handleRender(RenderRequest request, RenderResponse response, Object handler) throws Exception
Use the given handler to handle this render request. The workflow that is required may vary widely.- 参数:
request- current render requestresponse- current render responsehandler- handler to use. This object must have previously been passed to thesupportsmethod of this interface, which must have returnedtrue.- 返回:
- ModelAndView object with the name of the view and the required model data, or
nullif the request has been handled directly - 抛出:
Exception- in case of errors- 另请参阅:
Portlet.render(javax.portlet.RenderRequest, javax.portlet.RenderResponse)
handleResource
ModelAndView handleResource(ResourceRequest request, ResourceResponse response, Object handler) throws Exception
Use the given handler to handle this resource request. The workflow that is required may vary widely.- 参数:
request- current render requestresponse- current render responsehandler- handler to use. This object must have previously been passed to thesupportsmethod of this interface, which must have returnedtrue.- 返回:
- ModelAndView object with the name of the view and the required model data, or
nullif the request has been handled directly - 抛出:
Exception- in case of errors- 另请参阅:
ResourceServingPortlet.serveResource(javax.portlet.ResourceRequest, javax.portlet.ResourceResponse)
handleEvent
void handleEvent(EventRequest request, EventResponse response, Object handler) throws Exception
Use the given handler to handle this event request. The workflow that is required may vary widely.- 参数:
request- current action requestresponse- current action responsehandler- handler to use. This object must have previously been passed to thesupportsmethod of this interface, which must have returned true.- 抛出:
Exception- in case of errors- 另请参阅:
EventPortlet.processEvent(javax.portlet.EventRequest, javax.portlet.EventResponse)