需要有关JSF和<ui:insert>,<ui:define> </ui:define> </ui:insert>的帮助

时间:2014-11-18 23:10:33

标签: java html jsf

我对这个简单的代码有疑问,我无法查看&#34; footer.xhtml&#34;内容恰当(单词&#34; Wooorks&#34;)

web.xml

&#13;
&#13;
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
  <display-name>piloto_18</display-name>
  <welcome-file-list>
    <welcome-file>layout.xhtml</welcome-file>
  </welcome-file-list>
  <servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.xhtml</url-pattern>
  </servlet-mapping>
</web-app>
&#13;
&#13;
&#13;

layout.xhtml

&#13;
&#13;
<!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:h="http://java.sun.com/jsf/html">
    
    <h:head>

        <title>Facelets Template</title>
    </h:head>
    
    <h:body>
            <ui:insert name="footer">Not working</ui:insert>
    </h:body>
</html>
&#13;
&#13;
&#13;

footer.xhtml

&#13;
&#13;
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      template="layout.xhtml">
	 
	 <ui:define name="footer"> working!!! </ui:define>
</ui:composition>
&#13;
&#13;
&#13;

任何帮助将不胜感激:)

1 个答案:

答案 0 :(得分:0)

你应该在layout.xhtml中使用ui:include来包含footer.xhtml。

<强> layout.xhtml

<h:head>

    <title>Facelets Template</title>
</h:head>

<h:body>
        <ui:include src="footer.xhtml"/>
</h:body>

<强> footer.xhtml

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

     <p> working!!! </p>
</ui:composition>