簡體   English   中英

模板不適用於jsf 1.2

[英]Template not working on jsf 1.2

我對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>

(template.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”,也沒有看到標題。 為什么?

在此先感謝所有。

您還必須在header.html中使用<u:define name="header"> ,就像在index.html中使用<u:define name="content"> 如果要在模板中插入“其他”而不定義每個部分,只需在模板中使用<u:insert /> 這會將每個未定義的塊插入模板。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM