org.springframework.web.servlet.mvc |
Standard controller implementations for the servlet MVC framework that comes
with Spring. Provides both abstract base classes and concrete implementations
for often seen use cases.
A Controller - as defined in this package - is analogous to a Struts
Action . Usually Controllers are JavaBeans
to allow easy configuration using the {@link org.springframework.beans org.springframework.beans}
package. Controllers define the C from so-called MVC paradigm
and can be used in conjunction with the {@link org.springframework.web.servlet.ModelAndView ModelAndView}
to achieve interactive applications. The view might be represented by a
HTML interface, but, because of model and the controller being completely
independent of the view, PDF views are possible, as well as for instance Excel
views.
How to actually set up a (web)application using the MVC framework Spring
provides is explained in more detail in the
MVC-Step-by-Step
tutorial, also provided in this package (or have a look
here for an online version).
The classes contained by this package explain in more detail the actual
workflow of some of the abstract and concrete controller and how to extend
and fully use their functionality.
Especially useful to read, while getting into the Spring MVC framework
are the following:
|
Java Source File Name | Type | Comment |
AbstractCommandController.java | Class | Abstract base class for custom command controllers.
Autopopulates a command bean from the request. |
AbstractController.java | Class | Convenient superclass for controller implementations, using the Template
Method design pattern.
As stated in the
org.springframework.web.servlet.mvc.Controller Controller interface, a lot of functionality is already provided by certain abstract
base controllers. |
AbstractFormController.java | Class | Form controller that auto-populates a form bean from the request.
This, either using a new bean instance per request, or using the same bean
when the sessionForm property has been set to true .
This class is the base class for both framework subclasses like
SimpleFormController SimpleFormController and
AbstractWizardFormController AbstractWizardFormController , and
custom form controllers you can provide yourself.
Both form-input views and after-submission views have to be provided
programmatically. |
AbstractUrlViewController.java | Class | Abstract base class for Controllers that return a view name
based on the request URL.
Provides infrastructure for determining view names from URLs and configurable
URL lookup. |
AbstractWizardFormController.java | Class | Form controller for typical wizard-style workflows.
In contrast to classic forms, wizards have more than one form view page.
Therefore, there are various actions instead of one single submit action:
- finish: trying to leave the wizard successfully, that is, perform its
final action, and thus requiring a valid state;
- cancel: leaving the wizard without performing its final action, and
thus without regard to the validity of its current state;
- page change: showing another wizard page, e.g.
|
BaseCommandController.java | Class | Controller implementation which creates an object (the command object) on
receipt of a request and attempts to populate this object with request parameters.
This controller is the base for all controllers wishing to populate
JavaBeans based on request parameters, validate the content of such
JavaBeans using
org.springframework.validation.Validator Validators and use custom editors (in the form of
java.beans.PropertyEditor PropertyEditors ) to transform
objects into strings and vice versa, for example. |
CancellableFormController.java | Class | Extension of SimpleFormController that supports "cancellation"
of form processing. |
Controller.java | Interface | Base Controller interface, representing a component that receives
HttpServletRequest and HttpServletResponse
instances just like a HttpServlet but is able to
participate in an MVC workflow. |
HttpRequestHandlerAdapter.java | Class | Adapter to use the plain
org.springframework.web.HttpRequestHandler interface with the generic
org.springframework.web.servlet.DispatcherServlet . |
LastModified.java | Interface | Supports last-modified HTTP requests to facilitate content caching. |
ParameterizableViewController.java | Class | Trivial controller that always returns a named view. |
ServletForwardingController.java | Class | Spring Controller implementation that forwards to a named servlet,
i.e. |
ServletWrappingController.java | Class | Spring Controller implementation that wraps a servlet instance which it manages
internally. |
SimpleControllerHandlerAdapter.java | Class | Adapter to use the plain
Controller workflow interface with
the generic
org.springframework.web.servlet.DispatcherServlet . |
SimpleFormController.java | Class | Concrete FormController implementation that provides configurable
form and success views, and an onSubmit chain for convenient overriding.
Automatically resubmits to the form view in case of validation errors,
and renders the success view in case of a valid submission.
The workflow of this Controller does not differ much from the one described
in the
AbstractFormController AbstractFormController . |
UrlFilenameViewController.java | Class | Simple Controller implementation that transforms the virtual
path of a URL into a view name and returns that view. |
WebContentInterceptor.java | Class | Interceptor that checks and prepares request and response. |