【发布时间】:2019-03-31 16:50:56
【问题描述】:
这看起来很傻,但我不知道为什么它不起作用,我有以下项目树:
在dashboard.xhtml 中,我有一个按钮,必须将用户重定向到RequisicoesEmAberto.xhtml。
这是我在使用 html 按钮时尝试的:
<button id="reqAbertoBtn" class="btnAcessoRapido" onclick="ClickEvent()">
<div class="iconeBtnAcessoRapido">
<i class="fal fa-folder-open"></i>
</div>
<span class="tituloBtnAcessoRapido">Requisições em Aberto</span>
</button>
function ClickEvent() {
window.location.href = '/evop/protected/compras/requisicao/RequisicoesEmAberto.xhtml';
}
但是页面只刷新了,然后我决定为此尝试一个 PrimeFaces 组件,所以我尝试了:
<p:commandButton icon="fal fa-folder-open" iconPos="top" value="Requisições em Aberto" action="/evop/protected/compras/requisicao/RequisicoesEmAberto.xhtml?faces-redirect=true"/>
因此,当我单击按钮时,会出现一个错误,提示无法找到资源“/evop/protected/compras/requisicao/RequisicoesEmAberto.xhtml”,但页面在那里,如果您键入,则可以访问它浏览器中的网址。
我也尝试过使用结果:
<p:button icon="fal fa-folder-open" iconPos="top" value="Requisições em Aberto" outcome="/evop/protected/compras/requisicao/RequisicoesEmAberto.xhtml"/>
和
<p:button icon="fal fa-folder-open" iconPos="top" value="Requisições em Aberto" outcome="../compras/requisicao/RequisicoesEmAberto.xhtml"/>
和
<p:button icon="fal fa-folder-open" iconPos="top" value="Requisições em Aberto" outcome="RequisicoesEmAberto.xhtml"/>
针说那也给我报错了:
Could not resolve NavigationCase for outcome: /evop/protected/compras/requisicao/RequisicoesEmAberto.xhtml
我不敢相信做一个简单的页面重定向这么难,我在这里错过了什么?
【问题讨论】:
-
几乎好像您正在使用 JSF 1.x ?在 JSF 1.x 中,您必须在
faces-config.xml中定义导航规则。如果你不确定 - 你能告诉我们你的类路径吗?
标签: jsf redirect primefaces