我正在使用JSF来渲染一个HTML页面。我像这样设计页面:
<f:view xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core">
<h:head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<meta name="language" content="fr" />
<title><ui:insert name="title">My app</ui:insert></title>
</h:head>
<h:body>
<div id="top">
<ui:include src="/header.xhtml"/>
</div>
<h:panelGroup id="center" layout="block" >
<ui:insert name="center"/>
</h:panelGroup>
<div id="bottom">
<ui:include src="/footer.xhtml"/>
</div>
</h:body>
这个模板有一些“客户端”页面,比如这个:
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui"
template="/layouts/master.xhtml">
<ui:define name="center">
<ui:define name="title"><h:outputText value="#{myBean.description}"/></ui:define>
<ui:include src="#{myBean.url}"/>
</ui:define>
在客户端,我需要在头部添加元信息。如果我们有像outputScript或outputStylesheet这样的标签,可以在文档的任何地方设置并在html“head”标签中呈现,那将非常棒。
我没有找到方法来实现这个功能。在这种情况下,是否有一种方法可以在头部添加标签? 谢谢!
h:outputStylesheet
你是对的,但是你似乎没有测试过h:outputScript
。我已经更新了答案。 - BalusC