我在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>
我无法访问user
文件夹下的userData.xhtml
(和任何其他),并且出现上述异常。 我在user
文件夹下放置了一个纯HTML页面,可以访问它。
我尝试了很多东西,但找不到问题。任何帮助表示赞赏。
使用 url=" 更改结果标记
<p:menuitem value="About Us" url="about.xhtml" icon="ui-icon-help" />