【问题标题】:Template not working on jsf 1.2模板不适用于 jsf 1.2
【发布时间】:2013-09-03 05:10:58
【问题描述】:

我在使用 jsf 1.2 时遇到了问题,尤其是在模板加载方面。 我的 web.xml 打开 index.xhtml。

(index.xhtml)

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:c="http://java.sun.com/jstl/core"
    xmlns:a4j="http://richfaces.org/a4j"
    xmlns:rich="http://richfaces.org/rich"
    template="template.xhtml">

    <ui:define name="content">
        <h1>H1 index</h1>
    </ui:define>
</ui:composition>

(模板.xhtml)

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:a4j="http://richfaces.org/a4j"
    xmlns:rich="http://richfaces.org/rich">
<head>
<title>Titolo</title>
</head>
<body>
    <ui:include src="header.xhtml" />

    <ui:insert name="content" />

</body>
</html>

(header.xhtml)

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:c="http://java.sun.com/jstl/core"
    xmlns:a4j="http://richfaces.org/a4j"
    xmlns:rich="http://richfaces.org/rich">

<h:outputText value="This is the header 23456"/>

</ui:composition>

当我运行我的应用程序时,我只看到“H1 索引”。我没有看到“这是标题 23456”,也没有看到标题。为什么?

在此先感谢大家。

【问题讨论】:

    标签: jsf-1.2


    【解决方案1】:

    您也必须在 header.html 中使用 &lt;u:define name="header"&gt;,就像在 index.html 中使用 &lt;u:define name="content"&gt; 一样。如果您想在模板中插入“其他任何内容”而不定义每个部分,只需在模板中使用&lt;u:insert /&gt;。这会将每个未定义的块插入到您的模板中。

    【讨论】:

    • 感谢您的回复。对不起,它不起作用。似乎 template.xhtml 不工作,所以没有任何 xhtml 工作。 index.xhtml 有效,因为它在 web.xml 定义中。你有其他想法吗?
    猜你喜欢
    • 2011-01-20
    • 2017-10-13
    • 1970-01-01
    • 1970-01-01
    • 2012-02-15
    • 2015-07-23
    • 2013-01-07
    • 2023-03-28
    • 1970-01-01
    相关资源
    最近更新 更多