我在尝试将p:menuitem添加到菜单时遇到问题。下面的代码是一个菜单栏的文件,它将包含在其他网页上。
<ui:composition
xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ps="http://primefaces.org/spark"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui">
<h:outputStylesheet name="css/spark-layout-blue.css" library="spark-layout" />
<h:form>
<ps:menu id="layout-menu">
<p:submenu label="Opções" >
<p:menuitem />
</p:submenu>
</ps:menu>
</h:form>
不管我在p:menuitem里面放了什么,当我试着运行它时,我得到了这个:
HTTP Status 500 - org.primefaces.model.menu.MenuItem.getClientId()Ljava/lang/String;
type Exception report
message org.primefaces.model.menu.MenuItem.getClientId()Ljava/lang/String;
description The server encountered an internal error that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: org.primefaces.model.menu.MenuItem.getClientId()Ljava/lang/String;
javax.faces.webapp.FacesServlet.service(FacesServlet.java:659)
org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:70)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
root cause
java.lang.NoSuchMethodError: org.primefaces.model.menu.MenuItem.getClientId()Ljava/lang/String;
org.primefaces.spark.component.menu.SparkMenuRenderer.encodeElement(SparkMenuRenderer.java:87)
org.primefaces.spark.component.menu.SparkMenuRenderer.encodeElements(SparkMenuRenderer.java:77)
org.primefaces.spark.component.menu.SparkMenuRenderer.encodeSubmenu(SparkMenuRenderer.java:264)
org.primefaces.spark.component.menu.SparkMenuRenderer.encodeElement(SparkMenuRenderer.java:115)
org.primefaces.spark.component.menu.SparkMenuRenderer.encodeElements(SparkMenuRenderer.java:77)
org.primefaces.spark.component.menu.SparkMenuRenderer.encodeMarkup(SparkMenuRenderer.java:59)
org.primefaces.component.menu.BaseMenuRenderer.encodeEnd(BaseMenuRenderer.java:105)
javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:919)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:1903)
javax.faces.render.Renderer.encodeChildren(Renderer.java:176)
javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:889)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:1896)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:1899)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:1899)
com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:451)
com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:131)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:120)
com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:219)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:647)
org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:70)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
如果我把p:menuitem关掉,它会正常运行。
帮忙吗?
. lang。NoSuchMethodError: org.primefaces.model.menu.MenuItem.getClientId () Ljava/lang/String;
该方法已在PrimeFaces 5.0中添加。因此,这个问题意味着您在运行时类路径中使用了较旧的PrimeFaces版本,这与Spark不兼容。升级。