| 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 (the generic command framework from WebWork2) does
but just for ease of testing.
A ThrowawayController differs from the command notion of Base- or
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.
author: Juergen Hoeller since: 08.12.2003 See Also: org.springframework.web.servlet.mvc.Controller See Also: org.springframework.web.servlet.mvc.AbstractCommandController |