我正在使用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