小编Dav*_*vid的帖子

如何在插入的页面中包含切片定义属性

我有一个具有这些定义的tiles-defs.xml ...

<definition name="masterLayout" path="/WEB-INF/tiles-layouts/globalLayout.jsp">
    <put name="pageTemplate" value="over-ride for each page" />
</definition>

<definition name="childLayout" extends="masterLayout">
    <put name="pageTemplate" value="/WEB-INF/tiles-layouts/child/layout.jsp" />
    <put name="title" value="page title" />
    <put name="metaKeywords"    value="" />
    <put name="metaDescription" value="" />
    <put name="body"            value="/child/pagebody.jsp"/>
    <putList name="list">
        <add value="title" />
        <add value="metaKeywords" />
        <add value="metaDescription" />
        <add value="body" />
    </putList>
</definition>
Run Code Online (Sandbox Code Playgroud)

在globalLayout.jsp中我有这个工作,但我不会总是知道子定义添加到页面的属性.

<tiles:insert attribute="pageTemplate">
<tiles:put name="title"><tiles:getAsString name="title" /></tiles:put>
<tiles:put name="metaKeywords"><tiles:getAsString name="metaKeywords" /></tiles:put>
<tiles:put name="metaDescription"><tiles:getAsString name="metaDescription" /></tiles:put>
<tiles:put name="body"><tiles:getAsString name="body" /></tiles:put>
Run Code Online (Sandbox Code Playgroud)

由于子定义不会始终包含相同的属性.有没有办法在子定义中使用putList将属性放入globalLayout.jsp中的子页面范围?我尝试了以下,但它失败了

<%@ page import="java.util.Iterator" %>
<tiles:importAttribute />
<bean:define id="list" …
Run Code Online (Sandbox Code Playgroud)

jsp struts tiles

3
推荐指数
2
解决办法
3万
查看次数

标签 统计

jsp ×1

struts ×1

tiles ×1