For your Tiles views, Spring provides org.springframework.web.servlet.view.tiles.
TilesView,and you can use this as the viewClass property of an InternalResourceViewResolver,
or, as always, configure Tiles views individually in a ResourceBundleViewResolveror
XmlViewResolver. Listing 8-15 shows an InternalResourceViewResolverthat will be used to
return TilesViews.
Listing 8-15.TilesView Resolution
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="requestContextAttribute" value="requestContext"/>
<property name="viewClass"
value="org.springframework.web.servlet.view.tiles.TilesView"/>
</bean>
To bring it all together, the ViewResolverwill resolve the Viewnamed home, which our
Controllersets as the View’s key by looking in the definition file. In WEB-INF/tiles/defs-main.xml
shown earlier, the definition has such a key name, so Tiles uses this layout. Listing 8-16 shows
the content of the tiles-home.jsp.
Listing 8-16.Tiles Layout JSP
<%@ taglib prefix="tiles"
uri="http://jakarta.apache.org/struts/tags-tiles" %>
<%@ taglib prefix="fmt"
uri="http://java.sun.com/jstl/fmt" %>
<html>
<head>
<link rel="stylesheet" type="text/css" href="styles.css"/>
<title><fmt:message key="title"/></title>
</head>
<body>
<h1>Tiled Home Page</h1>
<p class="menu">
<a href="home.html">home</a> |
<a href="specials.html">specials</a> |
<a href="search.html">flight search</a>
</p>
<tiles:insert name="content"/>
</body>
</html>
234 CHAPTER 8 ■SUPPORTED VIEW TYPES