2011-03-16 90 views
1

我有一个主模板,它具有一般的站点布局框架:“/WEB-INF/jsp/common.jsp” 然后,我有另一个模板,通常用于另一个具有相似布局的页面:“/ WEB -INF/jsp/features/common.jsp“如何在瓷砖中扩展模板?

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

我试图解决这个问题的方式如下:

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

任何想法?

回答

1

我猜你需要的是nesting definitions。你可以尝试这样的事情。

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

这与我的有何不同? – 2011-03-16 12:03:52

+0

@Piotr。如果你仔细看看,在我的例子中,内容包含* subdefinition *值 – Raghuram 2011-03-16 12:14:39

+0

好吧,我试过并得到了“org.apache.tiles.template.NoSuchAttributeException:属性'rightContent'找不到。 ”。问题在于“rightContent”位于特性通用模板中。任何其他想法? – 2011-03-16 13:06:51