Expert Spring MVC and Web Flow

(Dana P.) #1
</tr>
</thead>
<tbody>
<c:forEach items="${flights}" var="flight">
<tr>
<td>${flight.numberOfLegs}</td>
<td>${flight.totalTravelTime}</td>
<td>$${flight.totalCost}</td>
</tr>
</c:forEach>
</tbody>
</table>

</body>
</html>

At this point, this page shouldn’t look too exciting. After rendering, the browser should
display a page that looks like the one in Figure 4-7.

Figure 4-7.The success view for Find Flights

Summary


The second use case, searching for available flights, introduced Spring MVC’s support for
XHTML forms. Many new classes and techniques were introduced for the first time, none as
important as the SimpleFormController.
The go-to class for handling form submissions is definitely the SimpleFormController,
for it manages the entire life cycle of an XHTML form from viewing the form, to validation, to
processing, and finally to directing to the success page. This Controlleris as powerful as it is
configurable, but its defaults are more than enough to quickly handle forms.
XHTML forms are encapsulated by POJOs named command beans, containing getters
and setters matching the fields found in the form. Command beans can contain properties of
all different types, from simple types to simple and complex classes. PropertyEditorsare used

74 CHAPTER 4 ■JUMP INTO SPRING MVC

Free download pdf