导航规则导致JSF1064:无法找到或服务资源
我有以下xhtml页面,它被包装在我的项目中其他页面的主要部分中:导航规则导致JSF1064:无法找到或服务资源,jsf,navigation,faces-config,Jsf,Navigation,Faces Config,我有以下xhtml页面,它被包装在我的项目中其他页面的主要部分中: <ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://xmlns.jcp.org/jsf/html" xmlns:ui="http://java.sun.com/jsf/facelet
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui">
<h:head>
<title></title>
</h:head>
<h:form>
<p:menubar>
<p:menuitem value="Home" url="/protected/personal/HomeCalendar.xhtml" icon="ui-icon-home"/>
<p:menuitem value="#{topbarBean.username}" url="#" style="text-decoration: underline" />
<f:facet name="options">
<p:inputText style="margin-right:20px" placeholder="Search" value="#{searchBean.searched}"/>
<p:commandButton action="#{searchBean.search()}" type="submit" icon="ui-icon-search" />
</f:facet>
</p:menubar>
</h:form>
</ui:composition>
我不明白这个问题是与导航规则还是下一个xhtml页面有关 如果JSF找不到匹配的导航规则,就会发生这种情况。然后它将切换到隐式导航。即,结果将用作相对于当前上下文的实际视图ID 显然,当前视图ID位于
/protected/personal
中的某个位置。searchingResults
的结果与任何导航规则都不匹配,将触发到/protected/personal/searchingResults.xhtml
的隐式导航
您有两种选择:
/Components/TopBar.xhtml
显然是错误的。您可以按如下方式找到正确的选项:
System.out.println(FacesContext.getCurrentInstance().getViewRoot().getViewId());
它通常与浏览器地址栏中的上下文相对URI相匹配,只要不使用POST进行页到页导航。在
中使用此值faces config.xml
中删除
,并更改结果值和操作方法,如下所示:
private final String resultsOutcome = "/protected/SearchResults.xhtml";
public String search() {
return resultsOutcome;
}
NavigationHandler
方法也相当笨拙。即使是使用导航案例,也只需直接返回结果,而不是摆弄NavigationHandler
-Index,xhtml
-Web Pages { components , protected}
-components{TopBar.xhtml}
-protected {event,persona,user,SearchResults.xhtml}
-event{eventCreate,eventPage,eventEdit}
-personal{HomeCalendar,ManageSettings,ManageInvitations}
System.out.println(FacesContext.getCurrentInstance().getViewRoot().getViewId());
private final String resultsOutcome = "/protected/SearchResults.xhtml";
public String search() {
return resultsOutcome;
}