问题是
< p:menubar> ... < /p:menubar>正在实际网页中显示,而不是将其转换为菜单栏。代码段和页面源位于下方。
下面是一个简单的主菜单:
<!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"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui">
<h:head>
<title>Main menu</title>
</h:head>
<body>
<h:form>
<ui:composition>
<p:menubar>
<p:submenu label="home">
<p:menuitem value="Home" url="/faces/home.jsf"/>
</p:submenu>
<p:submenu label="doStuff">
<p:menuitem value="Do Stuff 1" url="#"/>
<p:menuitem value="Do Stuff 2" url="#"/>
</p:submenu>
</p:menubar>
</ui:composition>
</h:form>
</body>
</html>
部署时的页面源位于下方(注意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"><head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="PRAGMA" content="no-cache" />
<meta http-equiv="EXPIRES" content="-1" />
<meta http-equiv="Cache-Control" content="no-cache" />
<meta http-equiv="Cache-Control" content="no-store" />
<meta http-equiv="Cache-Control" content="must-revalidate" />
<meta http-equiv="Expires" content="Mon,8 Aug 2006 10:00:00 GMT" />
<title>Main Template</title></head>
<body>
<div id="header" class="outerFrame">
</div>
<div id="navigation" class="outerFrame">
<p:menubar>
<p:submenu label="home">
<p:menuitem value="Home" url="/faces/home.jsf"></p:menuitem>
</p:submenu>
<p:submenu label="doStuff">
<p:menuitem value="Do Stuff 1" url="#"></p:menuitem>
<p:menuitem value="Do Stuff 2" url="#"></p:menuitem>
</p:submenu>
</p:menubar>
</div>
<div id="leftMargin" class="outerFrame">
</div>
<div id="rightMargin" class="outerFrame">
</div>
<div id="content" class="content">
</div>
<div id="footer" class="outerFrame">
</div>
</body>
</html>