需要有关JSF和,的帮助(Need help about JSF and , )

编程入门 行业动态 更新时间:2024-10-21 06:45:18
需要有关JSF的帮助(Need help about JSF and , )

我有这个简单代码的问题,我无法正确查看“footer.xhtml”内容(单词“Wooorks”)

web.xml中

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

layout.xhtml

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

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">
	 
	 <ui:define name="footer"> working!!! </ui:define>
</ui:composition> 
  
 

任何帮助将不胜感激 :)

I have problems with this simple code, I cant view "footer.xhtml" content properly (the word "Wooorks")

web.xml

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

layout.xhtml

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

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">
	 
	 <ui:define name="footer"> working!!! </ui:define>
</ui:composition> 
  
 

Any help will be appreciated :)

最满意答案

你应该在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>

You should use ui:include in layout.xhtml to 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>

更多推荐

xhtml,http,footer,电脑培训,计算机培训,IT培训"/> <meta name="description

本文发布于:2023-08-05 07:36:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1428832.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:JSF

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!