我正在尝试在我的所有页面中包含一大块静态html。我尝试了下面的代码,但它没有用。我还尝试了其他一些方法,无法让它发挥作用。我正在阅读有关使用ui标签的某种方式,但我无法让它工作。使用JSF包含页面需要做什么。
<?xml version='1.0' encoding='UTF-8' ?>
<!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:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich">
<h:head>
...
</h:head>
<h:body>
<jsp:include src="/common/includes/founcred1.html" />
...
</h:body>
答案 0 :(得分:1)
鉴于标记的XML语法,您似乎使用Facelets(*.xhtml
)作为视图技术。 Facelets是一种完全独特的视图技术和JSP的后继者。您不应该在Facelets中使用JSP标记。暂时忘记JSP。使用Facelets标签。它们将由XML namespage xmlns:ui="http://java.sun.com/jsf/facelets"
声明。要在Facelets中包含页面片段,请使用<ui:include>
标记。
<?xml version='1.0' encoding='UTF-8' ?>
<!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:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich">
<h:head>
...
</h:head>
<h:body>
<ui:include src="/common/includes/founcred1.xhtml" />
</h:body>
</html>
您只需将founcred1.html
重命名为founcred1.xhtml
,然后将内容换成<ui:composition>
。
<ui:composition
xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets">
<p>HTML here</p>
</ui:composition>
答案 1 :(得分:0)
xmlns:jsp="http://java.sun.com/JSP/Page"
<jsp:directive.include file="xxx.jspx"/>