[英]how to include multiple xhtml pages, which are extending same template into a summary xhtml page,
我们如何将多个xhtml页面包含在摘要页面中。 这里所有的xhtml页面都包含相同的模板。
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:ui="http://java.sun.com/jsf/facelets">
<head>
<title> SNS </title>
<meta http-equiv="expires" content="0"/>
<meta http-equiv="pragma" content="no-cache"/>
<meta http-equiv="cache-control" content="no-cache"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" href="sns.css" type="text/css" />
</head>
<h:body>
<div id="header">
<ui:insert name="commonHeader">
<ui:include src="header.xhtml" />
</ui:insert>
</div>
<div id="content">
<ui:insert name="commonBodyContent">
Common Body Content.
</ui:insert>
</div>
<div id="footer">
<ui:insert name="commonFooter">
<ui:include src="footer.xhtml" />
</ui:insert>
</div>
</h:body>
</html>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
template="commonTemplate.xhtml">
<ui:define name="commonBodyContent">
.........;
..........;
</ui:define>
</ui:composition>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
template="commonTemplate.xhtml">
<ui:define name="commonBodyContent">
.........;
..........;
</ui:define>
</ui:composition>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
template="commonTemplate.xhtml">
<ui:define name="commonBodyContent">
.........;
..........;
</ui:define>
</ui:composition>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets">
<ui:include src="updatePersonalDetails.xhtml" />
<ui:include src="updatedAddress.xhtml" />
<ui:include src="selectPreferences.xhtml" />
</ui:composition>
无论我在所有xhtml页面中的数据是什么,都应该在摘要页面中显示完全相同。 但包括这会导致多个<html>
文档在页面上呈现。
我们怎么解决这个问题?
将正文内容移动到模板客户端中由<ui:include>
包含的另一个模板中。
例如updatePersonalDetails.xhtml
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
template="commonTemplate.xhtml">
<ui:define name="commonBodyContent">
<ui:include src="updatePersonalDetails-content.xhtml" />
</ui:define>
</ui:composition>
(也为其他人重复)
所以你可以在summary.xhtml
这样做:
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
template="commonTemplate.xhtml">
<ui:define name="commonBodyContent">
<ui:include src="updatePersonalDetails-content.xhtml" />
<ui:include src="updatedAddress-content.xhtml" />
<ui:include src="selectPreferences-content.xhtml" />
</ui:define>
</ui:composition>
与具体问题无关 ,请考虑在/WEB-INF
文件夹中放置模板和包含,以防止直接访问它们。 另请参阅哪些XHTML文件需要放入/ WEB-INF,哪些不是?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.