接口 Controller
- 所有已知实现类:
AbstractController
,ParameterizableViewController
,PortletModeNameViewController
,PortletWrappingController
public interface Controller
Base portlet Controller interface, representing a component that receives RenderRequest/RenderResponse and ActionRequest/ActionResponse like aPortlet
but is able to participate in an MVC workflow.Any implementation of the portlet Controller interface should be a reusable, threadsafe class, capable of handling multiple portlet requests throughout the lifecycle of an application. To be able to configure Controller(s) in an easy way, Controllers are usually JavaBeans.
After the DispatcherPortlet has received a request and has done its work to resolve locales, themes and suchlike, it tries to resolve a Controller to handle that request, using a
HandlerMapping
. When a Controller has been found, thehandleRenderRequest
orhandleActionRequest
method will be invoked, which is responsible for handling the actual request and - if applicable - returning an appropriate ModelAndView. So actually, these method are the main entrypoint for theDispatcherPortlet
which delegates requests to controllers.So basically any direct implementation of the Controller interface just handles RenderRequests/ActionRequests and should return a ModelAndView, to be further used by the DispatcherPortlet. Any additional functionality such as optional validation, form handling, etc should be obtained through extending one of the abstract controller classes mentioned above.
- 从以下版本开始:
- 2.0
- 作者:
- William G. Thompson, Jr., John A. Lewis
- 另请参阅:
ResourceAwareController
,EventAwareController
,SimpleControllerHandlerAdapter
,AbstractController
,PortletContextAware
方法概要
所有方法 实例方法 抽象方法 修饰符和类型 方法 说明 void
handleActionRequest(ActionRequest request, ActionResponse response)
Process the action request.ModelAndView
handleRenderRequest(RenderRequest request, RenderResponse response)
Process the render request and return a ModelAndView object which the DispatcherPortlet will render.
方法详细资料
handleActionRequest
void handleActionRequest(ActionRequest request, ActionResponse response) throws Exception
Process the action request. There is nothing to return.- 参数:
request
- current portlet action requestresponse
- current portlet action response- 抛出:
Exception
- in case of errors
handleRenderRequest
ModelAndView handleRenderRequest(RenderRequest request, RenderResponse response) throws Exception
Process the render request and return a ModelAndView object which the DispatcherPortlet will render. Anull
return value is not an error: It indicates that this object completed request processing itself, thus there is no ModelAndView to render.- 参数:
request
- current portlet render requestresponse
- current portlet render response- 返回:
- a ModelAndView to render, or null if handled directly
- 抛出:
Exception
- in case of errors