一个或多个资源的目标是“头”

时间:2013-11-11 18:03:58

标签: jsf primefaces head

我有几个xhtml网站,使用PrimeFaces的网站打印此错误:一个或多个资源的目标是“head”

这是我的模板文件:

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

2 个答案:

答案 0 :(得分:1)

我正在以这种方式使用ui:

模板文件:

<!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>

答案 1 :(得分: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>