我正在将我的primefaces应用程序迁移到HTML5,当我将doctype更改为HTML5时,我发现了一些奇怪的东西。
我<p:menubar/>
与XHTML doctype完美配合:
<!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://xmlns.jcp.org/jsf/html"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:p="http://primefaces.org/ui">
<ui:composition>
<h:form id="menuForm">
<p:menubar id="appMenu">
<p:menuitem value="Celulares" url="#{menuMB.toMeusCelularesIndex()}" rendered="#{p:ifAnyGranted('USER')}" />
<p:submenu label="Celulares (Admin)" rendered="#{p:ifAnyGranted('ADMIN')}">
<p:menuitem value="Titulares (Corporativo)" url="#{menuMB.toCelularTitularIndex()}" rendered="#{p:ifAnyGranted('ADMIN')}" />
<p:menuitem value="Agregados" url="#{menuMB.toCelularAgregadoIndex()}" rendered="#{p:ifAnyGranted('ADMIN')}" />
</p:submenu>
<p:menuitem value="Ajuda" url="example.com" rendered="#{p:ifAnyGranted('USER')}" target="_blank"/>
<p:menuitem value="Sair" url="#{menuMB.toLogout()}" rendered="#{p:ifAnyGranted('USER')}" />
</p:menubar>
</h:form>
</ui:composition>
</html>
但是,当我只将页面doctype更改为HTML5 doctype(<!DOCTYPE html>
)时,菜单就会崩溃。看看我的代码:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:p="http://primefaces.org/ui">
<ui:composition>
<h:form id="menuForm">
<p:menubar id="appMenu">
<p:menuitem value="Celulares" url="#{menuMB.toMeusCelularesIndex()}" rendered="#{p:ifAnyGranted('USER')}" />
<p:submenu label="Celulares (Admin)" rendered="#{p:ifAnyGranted('ADMIN')}">
<p:menuitem value="Titulares (Corporativo)" url="#{menuMB.toCelularTitularIndex()}" rendered="#{p:ifAnyGranted('ADMIN')}" />
<p:menuitem value="Agregados" url="#{menuMB.toCelularAgregadoIndex()}" rendered="#{p:ifAnyGranted('ADMIN')}" />
</p:submenu>
<p:menuitem value="Ajuda" url="example.com" rendered="#{p:ifAnyGranted('USER')}" target="_blank"/>
<p:menuitem value="Sair" url="#{menuMB.toLogout()}" rendered="#{p:ifAnyGranted('USER')}" />
</p:menubar>
</h:form>
</ui:composition>
</html>
这里是截图: