|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
ThrowawayController is an alternative to Spring's default Controller interface, for executable per-request command instances that are not aware of the Servlet API. In contrast to Controller, implementing beans are not supposed to be defined as Servlet/Struts-style singletons that process a HttpServletRequest but rather as WebWork/Maverick-style prototypes that get populated with request parameters, executed to determine a view, and thrown away afterwards.
The main advantage of this controller programming model is that controllers are testable without HttpServletRequest/HttpServletResponse mocks, just like WebWork actions. They are still web UI workflow controllers: Spring does not aim for the arguably hard-to-achieve reusability of such controllers in non-web environments, as XWork does (the generic command framework from WebWork2) but just for ease of testing.
A ThrowawayController differs from the command notion of Base- respectively AbstractCommandController in that a ThrowawayController is an executable command that contains workflow logic to determine the next view to render, while BaseCommandController treats commands as plain parameter holders.
If binding request parameters to this controller fails, a fatal BindException will be thrown.
If you need access to the HttpServletRequest and/or HttpServletResponse, consider implementing Controller or deriving from AbstractCommandController. ThrowawayController is specifically intended for controllers that are not aware of the Servlet API at all. Accordingly, if you need to handle session form objects or even wizard forms, consider the corresponding Controller subclasses.
Controller
,
AbstractCommandController
Method Summary | |
ModelAndView |
execute()
Execute this controller according to its bean properties. |
Method Detail |
public ModelAndView execute() throws Exception
Exception
- in case of errors
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |