Java Reference
In-Depth Information
Listing 14.3
Tiles definition config
<tiles-definitions>
…
<definition name="layout.main" path="/pages/main.jsp" >
<put name="header"
value="/pages/common/header.jsp" />
<put name="footer"
value="/pages/common/footer.jsp" />
<put name="left"
value="/pages/common/left-blank.jsp" />
</definition>
<definition name="layout.catalog"
extends="layout.main" >
<put name="header"
value="/pages/common/header.jsp" />
<put name="footer"
value="/pages/common/footer.jsp" />
<put name="left"
value="/pages/common/left.jsp" />
</definition>
<definition name="index.tiles"
extends="layout.catalog" >
<put name="body"
value="/pages/catalog/Main.jsp" />
</definition>
…
<tiles-definitions>
In
tiles-defs.xml
there needs to be a
layout.main
and a
layout.catalog
defini-
tion before we can define
index.tiles
. The
index.tiles
definition extends the
layout.catalog
definition, which further extends the
layout.main
definition.
layout.main
defines the base template
JSP
located at
web/pages/main.jsp
in the
source tree.
Once we have our main page set up, we need to define a forward to it so that our
index.jsp
forward works. Note that we defined the
parameter
attribute as
index
in
our action mapping configuration. As a result, the
index()
method (listing 14.4)
will be called on the
catalogBean
before being forwarded to
/catalog/Main.jsp
.
Listing 14.4
Struts config action mapping
<action-mappings>
<action path="/index"
type="org.apache.struts.beanaction.BeanAction"









