English 中文(简体)
Apache瓷砖嵌套模板
原标题:
  • 时间:2009-05-12 18:37:21
  •  标签:

我找到: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>

但有趣的是,即使自己的文档是错误的:

2009-05-12 11:20:56,088[主要]错误——org.apache.commons.digester.Digester.error (Digester.java: 1635):解析错误在17列68行:“name”属性是必需的,必须指定元素类型“定义”。org.xml.sax。:都抛出SAXParseException异常属性“name”是必需的,必须指定元素类型“定义”。

虽然我为它定义一个名字,它仍然给了以下错误:

2009-05-12 11:35:31,818 [main] ERROR - org.apache.commons.digester.Digester.error(Digester.java:1635): Parse Error at line 21 column 19: The content of element type "put-attribute" must match "null". org.xml.sax.SAXParseException: The content of element type "put-attribute" must match "null".

这是什么意思? ! ! ! !

最佳回答

你使用的模式要求放置属性是一个叶节点,即t可以包含子元素,所以你不能这样做。发现一个新版本的模式(必须在瓷砖文档或例子)允许嵌套块模板。

-Kalle

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

问题回答

改变了DTD版本2.1解决了我的问题!





相关问题
热门标签