嵌套的Apache Tiles模板 [英] Nesting Apache Tiles Template
问题描述
于是我发现了这个: http://tiles.apache.org /framework/tutorial/advanced/nesting-extending.html
下面是例子:
<definition name="myapp.homepage" template="/layouts/classic.jsp">
<put-attribute name="title" value="Tiles tutorial homepage" />
<put-attribute name="header" value="/tiles/banner.jsp" />
<put-attribute name="menu" value="/tiles/common_menu.jsp" />
<put-attribute name="body">
<definition template="/layouts/three_rows.jsp">
<put-attribute name="one" value="/tiles/headlines.jsp" />
<put-attribute name="two" value="/tiles/topics.jsp" />
<put-attribute name="one" value="/tiles/comments.jsp" />
</definition>
</put-attribute>
<put-attribute name="footer" value="/tiles/credits.jsp" />
</definition>
所以我定义的:
<definition name="mgmt.base.layout" extends="base.layout">
<put-attribute name="body">
<definition template="/WEB-INF/mgmt/config/mgmtBody.jsp"/>
<put-attribute name="adminLeft" value="/WEB-INF/mgmt/config/left.jsp"/>
<put-attribute name="adminRight" value="/tiles/blank.html"/>
</definition>
</put-attribute>
</definition>
但有趣的是,即使自己的文件是错误的:
But the funny part is that, even their own documentation is wrong:
2009-05-12 11:20:56088 [主]错误 - org.apache.commons.digester.Digester.error(Digester.java:1635):在解析错误行17列68:属性 name是必需的,必须为元素类型指定定义。 org.xml.sax.SAXParseException:属性名是必需的,并且必须为元素类型定义中指定
尽管我为它定义了一个名称,它仍然提供了以下错误:
Even though I define a name for it, it still gives the following error:
2009-05-12 11:35:31818 [主]错误 - org.apache.commons.digester.Digester.error(Digester.java:1635):在解析行21列19错误:内容元素类型的把属性必须空相匹配。
org.xml.sax.SAXParseException:元素类型的内容把属性必须空匹配
这是什么意思?!!!!
What is this mean?!!!!
推荐答案
在使用该模式要求把属性是叶节点,即不能包含子元素 - 所以你不能做到这一点。查找出来,如果模式的新版本(必须在瓷砖文档或例子),允许嵌套瓷砖的模板。
The schema you use requires that put-attribute is a leaf node, i.e. can't contain child elements - so you can't do that. Find out if a newer version of the schema (must be in Tiles docs or examples) allows for nested tiles templates.
-Kalle
所以基本上我是用瓷砖的旧版本,并使用新版本的模式:
这里是旧的嵌套模式中的语法:
的http://tiles.apache.org/2.0/framework/tutorial/advanced/nesting-extending.html
So basically I am using a older version of tiles and using new version schema: Here is the syntax for older nested schema: http://tiles.apache.org/2.0/framework/tutorial/advanced/nesting-extending.html
这篇关于嵌套的Apache Tiles模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!