我正在使用spring-mvc和spring-webflow開發我自己的項目。閱讀了一些關於spring webflow和ajax的文章後,我明白了更好的選擇是使用Apache Tiles來渲染視圖。從Sitemesh遷移到Apache Tiles
在Sitemesh中,我使用了一個標籤調用頭()。該模板中使用的標記允許呈現在生成的HTML上呈現的頁面的整個頭部屬性。
有什麼辦法可以在Apache Tiles中實現這個功能嗎?從我的閱讀我認爲我必須做到以下幾點:
兩個jps,一個與頁面的主體和另一個與頭部定義。以下是模板,頁面和圖塊定義的示例,以便更好地理解。
瓷磚定義
<tiles-definitions>
<definition name="base" template="/WEB-INF/view/templates/tileslayout.jsp">
<put-attribute name="title" value="Held - main page"/>
<put-attribute name="body" value=""/>
<put-attribute name="head" value=""/>
</definition>
<definition name="company.edit" extends="base">
<put-attribute name="head" value="/WEB-INF/view/company/editHeader.jsp"></put-attribute>
<put-attribute name="body" value="/WEB-INF/view/company/edit.jsp"></put-attribute>
</definition>
</tiles-definitions>
模板:
<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles" %>
<html>
<head>
-- css and scripts --
<tiles:insertAttribute name="head" ignore="true"/>
<!-- <decorator:head /> -->
</head>
<body>
--- menu definition ---
<div class="container-fluid">
<tiles:insertAttribute name="body"/>
<!-- <decorator:body/> -->
</div>
<hr/>
<footer>
-----
</footer>
</body>
</html>
公司網頁
<div class="container">
-- the page html code
</div>
頭公司網頁
<meta name="menu" content="company" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style>
.error {
color: red;
}
</style>
<script type="text/javascript">
$(document).ready(function() {
$('#name').focus();
});
</script>
有時頭可能更復雜。
生成的html是好的。但我不喜歡爲應該很簡單的東西定義兩個jps。
我做錯了什麼?
有沒有更好的方法來做到這一點?
非常感謝。有用的信息。 – 2012-04-19 13:49:25