嵌套 Apache Tiles 模板

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/854199/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 17:35:40  来源:igfitidea点击:

Nesting Apache Tiles Template

apachejspstruts2tiles2

提问by samsina

So I found this: http://tiles.apache.org/framework/tutorial/advanced/nesting-extending.html

所以我发现了这个:http: //tiles.apache.org/framework/tutorial/advanced/nesting-extending.html

Here is the example:

这是示例:

<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>

So I defined this:

所以我定义了这个:

<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:56,088 [main] ERROR - org.apache.commons.digester.Digester.error(Digester.java:1635): Parse Error at line 17 column 68: Attribute "name" is required and must be specified for element type "definition". org.xml.sax.SAXParseException: Attribute "name" is required and must be specified for element type "definition".

2009-05-12 11:20:56,088 [main] 错误 - org.apache.commons.digester.Digester.error(Digester.java:1635):第 17 行第 68 列解析错误:属性“名称”是必需的,并且必须为元素类型“定义”指定。org.xml.sax.SAXParseException:属性“名称”是必需的,并且必须为元素类型“定义”指定。

Even though I define a name for it, it still gives the following error:

即使我为它定义了一个名称,它仍然会出现以下错误:

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".

2009-05-12 11:35:31,818 [main] 错误 - org.apache.commons.digester.Digester.error(Digester.java:1635):第 21 行第 19 列的解析错误:元素类型的内容“put-属性”必须匹配“null”。org.xml.sax.SAXParseException:元素类型“put-attribute”的内容必须匹配“null”。

What is this mean?!!!!

这是什么意思?!!!!

回答by Bart Frackiewicz

Changing the DTD version to 2.1 solved my problem!

将 DTD 版本更改为 2.1 解决了我的问题!

回答by samsina

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.

您使用的架构要求 put-attribute 是叶节点,即不能包含子元素 - 所以您不能这样做。了解较新版本的架构(必须在 Tiles 文档或示例中)是否允许嵌套的 Tiles 模板。

-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

所以基本上我使用的是旧版本的瓷砖并使用新版本的架构:这是旧嵌套架构的语法:http: //tiles.apache.org/2.0/framework/tutorial/advanced/nesting-extending.html