开发者

how to insert a nest tiles

Hi: I know how to insert the attribut and defination in the jsp page,but I can not insert a nestly tiles.

This is the exmaple:

    <definition name="/commonPage" template="/jsp/common/template.jsp">
        <put-attribute name="header" value="/jsp/common/defaultHeader.jsp" />
        <put-attribute name="menu" value="/jsp/common/defaultMenu.jsp" />
        <put-attribute name="footer" value="/jsp/common/defaultFooter.jsp" />
    </definition>


    <definition name="/all" extends="/commonPage">
        <put-attribute name="body" value="/jsp/all_body.jsp" />
        <put-list-attribute name="scriptList">
            <add-attribute value="/res/script/all.js" />
        </put-list-attribute>
    </definition>

    <definition name="/time" extends="/commonPage">
        <put-attribute name="timebar" value="/jsp/common/timebar.jsp" />
        <put-attribute name="body" value="/jsp/time_body.jsp" />
        <put-list-attribute name="scriptList"></put-list-attribute>
    </definition>

</tiles-definitions>

And in the tempalte.jsp:

....
<tiles:insertAttribute name="meun">
...
<tiles:insertAttribute name="footer">

Now,in the time_body.jsp,I want to insert another jsp -- timebar.jsp.

So I define the attribute in the definition of "/time",however it does not work.

This is the codes in the time_body.jsp:

<div class="div_fullwidth">
  开发者_如何转开发  <tiles:insertAttribute name="timebar" />
</div>

Any ideas?


Did you get any error messages when you try to do that?

Edited: So this is my tiles configuration - I'm using spring:

Basic layout - holds general layout structure without page specific content in the body tag:

<tiles-definitions>

<definition name="default" template="/WEB-INF/layouts/default.jspx">
    <put-attribute name="leftmenu" value="/WEB-INF/layouts/partial/leftmenu.jspx" />
    <put-attribute name="footer" value="/WEB-INF/layouts/partial/footer.jspx" />
    <put-attribute name="subheader" value="/WEB-INF/layouts/partial/subheader.jspx" />
    <put-attribute name="seoheader" value="/WEB-INF/layouts/partial/seoheader.jspx" />
</definition>
    </tiles-definitions>

Page specific views:

<tiles-definitions>
<definition extends="default" name="advice/list">
    <put-attribute name="body" value="/WEB-INF/views/advice/list.jspx"/>
</definition>
</tiles-definitions>

So in that page specific view "advice/list" I want to add a new partial I'll do that:

<put-attribute name="timebar" value="/WEB-INF/layouts/partial/timebar.jspx" />

And then I will call simply the attribute in the advice/list template.

  1. Can you check if you set correctly tiles-definitions in your WEB-INF/web.xml file.
  2. Since you get not-found - can you try to change your template attribute path definition.

btw: I'm using that dependency in my pom.xml

<dependency>
   <groupId>org.apache.tiles</groupId>
   <artifactId>com.springsource.org.apache.tiles</artifactId>
   <version>2.1.3</version>
</dependency>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜