使用Wildcart支持扩展磁贴

时间:2015-01-27 06:31:10

标签: apache tiles

Tiles配置

<definition name="defaultLayout" template="/{1}/{2}/common/{4}/layouts/layout.jsp">
    <put-attribute name="header" value="header.jsp" />
    <put-attribute name="body" value="" />
    <put-attribute name="footer" value="/{1}/{2}/common/s/footer.jsp" />
</definition>
 <!-- Default Layout Defination over -->
<definition name="*/*/*/*/*/index" extends="defaultLayout">
    <put-attribute name="body" value="/{1}/{2}/common/s/index.jsp" />

问题是我的defaultLayout定义没有替换为子定义中的define wildcart。
当我在浏览器中点击了http://localhost:8080/etisalat/wap/common/b/index.wfv之后的网址,然后是 错误

HTTP Status 404 - /{1}/{2}/common/{4}/layouts/layout.jsp

type Status report

message /{1}/{2}/common/{4}/layouts/layout.jsp

description The requested resource (/{1}/{2}/common/{4}/layouts/layout.jsp) is not available.
Apache Tomcat/6.0.32

1 个答案:

答案 0 :(得分:1)

通配符占位符不会传递给继承的定义。

你需要

<definition name="defaultLayout.*.*.*" template="/{1}/{2}/common/{3}/layouts/layout.jsp">
    <put-attribute name="header" value="header.jsp" />
    <put-attribute name="body" value="" />
    <put-attribute name="footer" value="/{1}/{2}/common/s/footer.jsp" />
</definition>


<definition name="*/*/*/*/*/index" extends="defaultLayout.{1}.{2}.{4}">
    <put-attribute name="body" value="/{1}/{2}/common/s/index.jsp" />
    ...