Nesting Apache Tiles Template

2019-08-08 09:37发布

So I found this: 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".

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

What is this mean?!!!!

2条回答
等我变得足够好
2楼-- · 2019-08-08 09:53

Changing the DTD version to 2.1 solved my problem!

查看更多
Deceive 欺骗
3楼-- · 2019-08-08 09:53

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

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

查看更多
登录 后发表回答