Primefaces MenuItem结果属性上的空指针异常

时间:2014-01-12 12:45:31

标签: jsf-2 primefaces navigation

我在jsf 2.2 web项目中使用prime faces 4.0。我正在使用模板,包括页面的菜单栏和页脚部分。

我创建了一个名为user的文件夹,用于通过身份验证过滤器访问其下的页面,将未经授权的请求重定向到正确的页面。

但菜单栏上指向user文件夹下的页面的链接会引发异常,如下所示:

HTTP Status 500 -

type Exception report

message

description The server encountered an internal error that prevented it from fulfilling this request.

exception

javax.servlet.ServletException
    javax.faces.webapp.FacesServlet.service(FacesServlet.java:659)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
root cause

java.lang.NullPointerException
    org.primefaces.renderkit.OutcomeTargetRenderer.getTargetURL(OutcomeTargetRenderer.java:80)
org.primefaces.component.menu.BaseMenuRenderer.encodeMenuItem(BaseMenuRenderer.java:148)
org.primefaces.component.tieredmenu.TieredMenuRenderer.encodeElements(TieredMenuRenderer.java:103)
org.primefaces.component.tieredmenu.TieredMenuRenderer.encodeSubmenu(TieredMenuRenderer.java:162)
org.primefaces.component.tieredmenu.TieredMenuRenderer.encodeElements(TieredMenuRenderer.java:119)
org.primefaces.component.tieredmenu.TieredMenuRenderer.encodeMenu(TieredMenuRenderer.java:78)
org.primefaces.component.menubar.MenubarRenderer.encodeMarkup(MenubarRenderer.java:49)
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)
org.primefaces.renderkit.CoreRenderer.renderChild(CoreRenderer.java:70)
org.primefaces.renderkit.CoreRenderer.renderChildren(CoreRenderer.java:57)
org.primefaces.component.layout.LayoutUnitRenderer.encodeEnd(LayoutUnitRenderer.java:51)
javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:919)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:1903)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:1899)
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)
javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:337)
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.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
note The full stack trace of the root cause is available in the Apache Tomcat/7.0.47 logs.

Apache Tomcat/7.0.47

模板文件下的菜单项(位于WEB-INF目录下)如下所示:

<p:menuitem value="User Data" outcome="/user/userData" rendered="#{sessionBean.loggedIn}"/>

<p:menuitem icon="ui-icon-grip-dotted-vertical" rendered="#{sessionBean.loggedIn}"/>

<p:submenu label="Yardım" >
    <p:menuitem value="About Us" outcome="about" icon="ui-icon-help" />
</p:submenu>

我无法访问userData.xhtml文件夹下的user(以及任何其他文件夹),我得到上述例外情况。我在user文件夹下放置了一个简单的html页面,我可以访问它。

我尝试了很多东西,却找不到问题。 任何帮助赞赏。

1 个答案:

答案 0 :(得分:1)

使用url =&#34;&#34;

更改结果标记
<p:menuitem value="About Us" url="about.xhtml" icon="ui-icon-help" />