2

只要 JSPX 必须是格式良好的 XML,就无法在单独的包含文件中包含包含标记的 beginig 的标头部分,因为必须关闭。

看起来您必须始终包含在所有主页中?还是我错过了什么?

4

1 回答 1

2

Apache Tiles supposedly solves this problem, it allows you to template and re-use JSPX components.

Updated answer:

In your views.xml, you would have something like the following:

<definition extends="error" name="dataAccessFailure">
    <put-attribute name="body" value="/WEB-INF/views/dataAccessFailure.jspx"/>
</definition>

<definition extends="default" name="index">
    <put-attribute name="body" value="/WEB-INF/views/body/index.jspx"/>
    <put-attribute name="side" value="/WEB-INF/views/side/index.jspx"/>
</definition>

Both error and default are layouts I've defined in the layouts directory, error is a single column layout and default is a two column layout.

Also in the layouts directory is the layouts.xml:

<tiles-definitions>

    <definition name="default" template="/WEB-INF/layouts/default.jspx">
        <put-attribute name="header" value="/WEB-INF/views/header.jspx" />
        <put-attribute name="menu" value="/WEB-INF/views/navigation.jspx" />
        <put-attribute name="footer" value="/WEB-INF/views/footer.jspx" />
    </definition>

    <definition name="error" template="/WEB-INF/layouts/error.jspx">
        <put-attribute name="header" value="/WEB-INF/views/header.jspx" />
        <put-attribute name="menu" value="/WEB-INF/views/navigation.jspx" />
        <put-attribute name="footer" value="/WEB-INF/views/footer.jspx" />
    </definition>

</tiles-definitions>

I haven't personally done apache tiles integration by hand, I just use Spring ROO to generate a complete stack for me and then add / remove stuff as I need.

于 2011-04-17T17:47:33.070 回答