Expert Spring MVC and Web Flow

(Dana P.) #1

when conversion is required from the simple Strings returned by the HttpServletRequestto
more complex types found in the command bean. Spring ships with many PropertyEditors
handling common conversions, and it is easy to add your own.
Properties from the command bean are bound into XHTML form elements using the JSP
tag . This tag exposes a statusvariable with metadata about the property,
including its value, any errors, and the path name to the variable.


Now Let’s Learn How to Swim


At this point, you’ve seen the most important elements of the Spring MVC system, but you’ve
only begun to explore how configurable, flexible, and powerful they can be. Let’s review what
we’ve see so far.



  • Controllers perform an action when a web resource is requested by a client. They can
    be simple, as is the case with AbstractController, or complex like SimpleFormController.
    Spring MVC provides a rich assortment of Controllers that provide a solid foundation
    to build your application.

  • Views are single pages, usually created with a template language such as JSP, Velocity,
    or FreeMarker. Spring MVC also supports such technologies as PDF, Excel, and
    JasperReports. View systems can be mixed and matched in an application.

  • ViewResolvers translate a logical view name into a physical Viewinstance. This class is
    used to keep the Controllers blissfully unaware of the actual view technology in use.
    ViewResolvers can be chained together if multiple strategies are required.

  • The DispatcherServletmanages the entire processing pipeline of a HTTP request,
    delegating to a wide array of components to complete the request and generate the
    response. You’ve seen some of these components, such as Controllers and ViewResolvers,
    but there are many more such as file upload handlers and Localemanagers. The
    DispatcherServletis the Front Controller for the application, handling all incoming
    requests and choosing the right Controllerfor the job.


•Spring MVC provides JSP tags for binding properties from the command bean to form
elements. These tags provide metadata about the bean property, such as any errors
from validation or its current value. These tags are also available as macros for the
template languages Velocity and FreeMarker.

This introduction has shown you only the tip of the iceberg in terms of functionality and
configuration options. There is a wide array of Controllerimplementations to review, as well
as whole chapters devoted to validation and testing. But first thing’s first. In Chapter 5 we will
closely examine the processing pipeline provided by the DispatcherServlet, where you’ll see
what it takes to handle an incoming HTTP request.


CHAPTER 4 ■JUMP INTO SPRING MVC 75
Free download pdf