Apache 如何在平铺中扩展模板?

Apache 如何在平铺中扩展模板?,apache,jsp,tomcat,tiles,Apache,Jsp,Tomcat,Tiles,我有一个主模板,它具有一般的站点布局框架:“/WEB-INF/jsp/common.jsp” 然后,我有另一个模板,通常用于其他数量的具有类似布局的页面:“/WEB-INF/jsp/features/common.jsp” 功能模板基本上定义了“主”模板的属性“内容”的内容 我已尝试通过以下方式解决此问题: <definition name="product.common" template="/WEB-INF/jsp/common.jsp"> <put-attribu

我有一个主模板,它具有一般的站点布局框架:“/WEB-INF/jsp/common.jsp” 然后,我有另一个模板,通常用于其他数量的具有类似布局的页面:“/WEB-INF/jsp/features/common.jsp”

功能模板基本上定义了“主”模板的属性“内容”的内容

我已尝试通过以下方式解决此问题:

<definition name="product.common" template="/WEB-INF/jsp/common.jsp">
    <put-attribute name="content" value="/WEB-INF/jsp/features/common.jsp" />
</definition>
<definition name="features/index" extends="product.common">
    <put-attribute name="title" value="Features" />
    <put-attribute name="rightContent" value="/WEB-INF/jsp/features/index.jsp" />
</definition>

但这是行不通的。我在堆栈跟踪中收到以下错误消息:

org.apache.tiles.template.NoSuchAttributeException:未找到属性“rightContent”

但“功能”模板确实具有以下功能:

<tiles:insertAttribute name="rightContent" />

有什么想法吗?

我想你需要的是。你可以试试这样的

<definition name="features.common" template="/WEB-INF/jsp/features/common.jsp">
</definition>

<definition name="product.common" template="/WEB-INF/jsp/common.jsp">
    <put-attribute name="content" value="features.common" />
</definition>

<definition name="features/index" extends="product.common">
    <put-attribute name="title" value="Features" />
    <put-attribute name="rightContent" value="/WEB-INF/jsp/features/index.jsp" />
</definition>

我想你需要的是。你可以试试这样的

<definition name="features.common" template="/WEB-INF/jsp/features/common.jsp">
</definition>

<definition name="product.common" template="/WEB-INF/jsp/common.jsp">
    <put-attribute name="content" value="features.common" />
</definition>

<definition name="features/index" extends="product.common">
    <put-attribute name="title" value="Features" />
    <put-attribute name="rightContent" value="/WEB-INF/jsp/features/index.jsp" />
</definition>


这和我的有何不同?@Piotr。如果仔细看,在我的示例中,content包含一个子定义值ok,我尝试了一下,得到了“org.apache.tiles.template.NoSuchAttributeException:Attribute'rightContent'notfound.”。问题是“rightContent”在功能通用模板中。还有其他想法吗?解决方案是使用级联!:)谢谢你的帮助tho@Piotr. 如果您将答案添加到您的问题中会更好(如果您指向现有答案会更好:)。正如你所说,被接受的答案没有指向正确的方向。这和我的有什么不同?@Piotr。如果仔细看,在我的示例中,content包含一个子定义值ok,我尝试了一下,得到了“org.apache.tiles.template.NoSuchAttributeException:Attribute'rightContent'notfound.”。问题是“rightContent”在功能通用模板中。还有其他想法吗?解决方案是使用级联!:)谢谢你的帮助tho@Piotr. 如果您将答案添加到您的问题中会更好(如果您指向现有答案会更好:)。正如你所说,被接受的答案并没有指向正确的方向。