Definitionの名前をStruts forwardに使う
Ted HustedさんのThe Struts Catalogにもあるように、MVC2アーキテクチャーでは全てのページがコントローラ(Strutsではアクションマッピング)を通過しなければなりません。スタティックのページでもコントロールは一旦アクションに渡され、、struts-config.xmlのアクションマッピングで指定されたページにforwardされます。
通常Tilesで作ったレイアウトを使ったページをブラウザに表示するには .jsp のページを作成します。
例えば index.jsp だとこんな風になります。
<%@ include file="/WEB-INF/taglibs.jsp" %>
<%@ page contentType="text/html; charset=EUC-JP"%><tiles:insert definition="layout.MainLayout" flush="true">
<tiles:put name="title" value="izuLog トップページ" />
</tiles:insert>
例えば、product.jspというページを作成するかわりに、前に書いたsite.body.productを使います。
struts-config.xmlのアクションマッピング:
<action-mappings>
<action path="/product"
type="org.apache.struts.actions.ForwardAction"
parameter="site.body.product" />
...
</action-mappings>
(注) global forwardの中ではdefinition名を直接使うことは出来ません。