【问题标题】:JSF template overriding don't workJSF 模板覆盖不起作用
【发布时间】:2015-02-21 14:01:28
【问题描述】:

我的主要模板:

<h:body>


    <div id="top" class="top">
        <ui:insert name="top">Top</ui:insert>
    </div>
    <div>
        <div id="left">
            <ui:insert name="left"></ui:insert>
        </div>
        <div id="content" class="left_content">
            <ui:insert name="content">Content</ui:insert>
        </div>
    </div>
</h:body>

我的客户模板(应该覆盖上面的部分):

<body>

    <ui:composition template="./mainTemplate.xhtml">

        <ui:define name="top">
            top 123
        </ui:define>

        <ui:define name="left">
            left 123
        </ui:define>

        <ui:define name="content">
            content 123
        </ui:define>

    </ui:composition>

</body>

模板使用默认值加载,因此没有覆盖,我该如何解决这个问题?

【问题讨论】:

    标签: jsf jsf-2.2


    【解决方案1】:

    因为您没有加载客户端模板,如果您的 mainTemplate.xhtml 位于应用程序的根目录中,只需像这样使用它:template="/mainTemplate.xhtml" 没有 "."

    另外,请确保您使用正确的命名空间进行 faclet 声明,这适合您的情况(根据您的问题标签,我假设您使用 JSF 2.2):

    xmlns:ui="http://xmlns.jcp.org/jsf/facelets
    

    【讨论】:

      猜你喜欢
      • 2018-02-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-02-19
      • 1970-01-01
      • 2011-08-13
      • 1970-01-01
      相关资源
      最近更新 更多