次にsitemeshの設定。
sitemesh-page.tldとsitemesh-decorator.tldはStruts2のパッケージのshowcaseに含まれるそれらのファイルのコピーがそのまま使えるようだ。
WEB-INF/decorators/main.jspが、共通のレイアウトを決定しているようなので、これを自分のシステム用にカスタマイズして、[myapp]/WEB-INF/decorators/main.jspとして配置する。
sitemeshを使うには、web.xmlにフィルタとtaglibの設定もする。web.xmlに以下の内容を挿入する。(/servlet-mappingの後でresource-refの前)
----
<filter>
<filter-name>cleanup</filter-name>
<filter-class>org.apache.struts2.dispatcher.ActionContextCleanUp</filter-class>
</filter>
<filter>
<filter-name>sitemesh</filter-name>
<filter-class>com.opensymphony.module.sitemesh.filter.PageFilter</filter-class>
</filter>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>
<filter-mapping>
<filter-name>cleanup</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>sitemesh</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<taglib>
<taglib-uri>sitemesh-page</taglib-uri>
<taglib-location>/WEB-INF/sitemesh-page.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>sitemesh-decorator</taglib-uri>
<taglib-location>/WEB-INF/sitemesh-decorator.tld</taglib-location>
</taglib>