1、問題的提出
在開發Web 應用時,Web頁面可能由不同的人參與開發,因此開發出來的界面通常千奇百怪、五花八門,風格難以保持一致。
為了統一界面的風格,Struts 框架提供了一個標簽庫Tiles 來進行網頁的框架布局 。

2、SiteMesh 簡介
SiteMesh 是一個網頁布局和修飾的框架,利用它可以將網頁的內容和頁面結構分離,以達到頁面結構共享的目的。
Sitemesh是由一個基於Web頁面布局、裝飾以及與現存Web應用整合的框架。
它能幫助我們在由大量頁面構成的項目中創建一致的頁面布局和外觀,如一致的導航條,一致的banner,一致的版權,等等。
它不僅僅能處理動態的內容,如jsp,PHP,asp等產生的內容,它也能處理靜態的內容,如htm的內容,使得它的內容也符合你的頁面結構的要求。甚至於它能將HTML文件象include那樣將該文件作為一個面板的形式嵌入到別的文件中去。
3、開發步驟:
③ 在WEB-INF目錄下加入decorators.xml文件
<decorators defaultdir="/decorators"> <!--裝飾文件存放的目錄-->
<decorator name=" main" page=" main.jsp"> <!--裝飾文件為main.jsp-->
<pattern>/ test.jsp</pattern> <!--要被裝飾的頁面,如是“ /* ”指對WebContent\目錄下的所有JSP頁面進行裝飾-->
</decorator>
<decorator name="panel" page="panel.jsp"/>
<decorator name="printable" page="printable.jsp"/>
<pattern>/exclude.jsp</pattern>
<pattern>/exclude/*</pattern>
</ excludes>
</decorators>
<sitemesh>
<property name="decorators-file" value="/WEB-INF/decorators.xml"/>\
<excludes file="${decorators-file}"/>
<page-parsers>
<parser content-type="text/html" class="com.opensymphony.module.sitemesh.parser.FastPageParser"/>
</page-parsers>
<decorator-mappers>
<mapper class="com.opensymphony.module.sitemesh.mapper.ConfigDecoratorMapper">
<param name="config" value="${decorators-file}"/>
</mapper>
</decorator-mappers>
</sitemesh>
<head>
<title>My Site- <decorator:title default="Welcome!"/></title>
<decorator:head/>
</head>
<body>
<h1> <decorator:title default="Welcome to MyHouse"/></h1>
<p> <decorator:body/></p>
<p><small>(<a href=" #">printable version</a>)</small></p>
</body>
</html>
<head>
<title> Simple Document</title>
</head>
<body>
Hello World!<br/>
</body>
</html>
