<jsp:directive.page contentType="text/html;charset=UTF-8"/>
<jsp:output omit-xml-declaration="yes"/>
<h1>Contact Listing</h1>
<c:if test="${not empty contacts}">
<table>
<thead>
<tr>
<th>First Name</th>
<th>Last Name</th>
<th>Birth Date</th>
</tr>
</thead>
<tbody>
<c:forEach items="${contacts}" var="contact">
<tr>
<td>${contact.firstName}</td>
<td>${contact.lastName}</td>
<td><joda:format value="${contact.birthDate}" pattern="yyyy-MM-
dd"/></td>
</tr>
</c:forEach>
</tbody>
</table>
</c:if>
</div>
If you have developed JSP before, Listing 17-12 should be familiar to you. But since this is a JSPX
page, the page content is embedded under the <div> tag. In addition, the tag libraries being used are
declared as XML namespaces.
First, the <jsp:directive.page> tag defines the attributes that apply to the entire JSPX page, while
the <jsp:output> tag controls the properties of the output of the JSPX document.
Second, the tag <c:if> detects whether the model attribute contacts is empty. Because we already
populated some contact information in the database, the contacts attribute should contain data. As a
result, the <c:forEach> tag will render the contact information in the table within the page. Note the use
of the <joda:format> tag to format the birthDate attribute, which is of JodaTime's DateTime type.
Testing the Contact List View
Now we are ready to test the contact list view. First verify that the context root of the web application is
ch17. To do this, select the project, right-click, and select Properties. Then in the left menu, click the
option Web Project Settings and verify that the "Context root" setting is ch17, as shown in Figure 17-4.
Search WWH :
Custom Search
Previous Page
Spring Framework 3 Topic Index
Next Page
Spring Framework 3 Bookmarks
Home