0

我的 xhtml 网站很少,使用 PrimeFaces 的网站会打印此错误:一个或多个资源的目标是“头”

这是我的模板文件:

<html lang="pl"
  xmlns="http://www.w3.org/1999/xhtml"
  xmlns:h="http://java.sun.com/jsf/html"
  xmlns:p="http://primefaces.org/ui"
  xmlns:ui="http://java.sun.com/jsf/facelets">
<h:head>
    <meta content="text/html; charset=UTF-8" http-equiv="Content-type" />

    <link href="resources/css/bootstrap.css" rel="stylesheet"/>
    <link href="resources/css/font-awesome.css" rel="stylesheet"/>
    <link rel="stylesheet" type="text/css" href="resources/css/style.css"/>
    <link rel="stylesheet" type="text/css" href="resources/css/style-mobile.css"/>

    <script src="https://code.jquery.com/jquery-1.10.2.min.js"></script>
    <script src="resources/js/bootstrap.js"></script>
</h:head>
<h:body>
    <ui:insert name="header">
        <ui:include src="/global/top-menu.xhtml"/>
    </ui:insert>

    <ui:insert name="content">
        <ui:include src="/index.xhtml"/>
    </ui:insert>

    <ui:insert name="footer">
        <ui:include src="/global/footer.xhtml"/>
    </ui:insert>
</h:body>
</html>

这是打印错误的内容:

<!DOCTYPE html>
<html lang="pl"
      xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:ui="http://java.sun.com/jsf/facelets">
<h:head>

</h:head>

<h:body>
    <ui:composition template="/WEB-INF/template/mainLayout.xhtml">
        <ui:define name="content">

            <h:outputScript library="js" name="calendar-pl.js"/>
            <h:outputScript library="js" name="registration.js"/>

            <div class="container registration-container">
             //some PrimeFaces stuff which works properly by the way
            </div>

        </ui:define>
    </ui:composition>
</h:body>
</html>
4

2 回答 2

1

我以这种方式使用 ui:composition:

模板文件:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
  xmlns:ui="http://java.sun.com/jsf/facelets">
<f:view contentType="text/html" locale="en">
<h:head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <ui:insert name="headerExtend"></ui:insert>
</h:head>
<h:body>
         <ui:insert name="content"></ui:insert>
    </h:body>
 </f:view>
</html>

这是插入的实际内容:

<ui:composition
template="./layout.xhtml"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"

xmlns:p="http://primefaces.org/ui">
<ui:define name="content">
        <h:form>
        </h:form>
    </ui:define>
</ui:composition>
于 2013-11-12T09:46:46.297 回答
1

您会对视图文件的以下内容说什么:

<ui:composition 
    xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:p="http://primefaces.org/ui"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    template="/WEB-INF/template/mainLayout.xhtml">

    <ui:define name="content">

        <h:outputScript library="js" name="calendar-pl.js"/>
        <h:outputScript library="js" name="registration.js"/>

        <div class="container registration-container">
         //some PrimeFaces stuff which works properly by the way
        </div>

    </ui:define>
</ui:composition>
于 2013-11-12T18:58:06.703 回答