Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| The Spring Framework
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.springframework.web.servlet.mvc.throwaway
Interface ThrowawayController

    public interface ThrowawayController

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.

Since:
  08.12.2003
Author:
  Juergen Hoeller
See Also:
  `Controller`, `AbstractCommandController`

Method Summary
`ModelAndView` | `execute()` Execute this controller according to its bean properties.

Method Detail

### execute

    ModelAndView execute()
                         throws Exception

  Execute this controller according to its bean properties. Gets invoked after a new instance of the controller has been populated with request parameters. Is supposed to return a ModelAndView in any case, as it is not able to generate a response itself.

  Returns:
    a ModelAndView to render
  Throws:
    `Exception` - in case of errors

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| The Spring Framework
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2002-2007 The Spring Framework.