【问题标题】:Can't redirect in JSF [duplicate]无法在 JSF 中重定向 [重复]
【发布时间】: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


【解决方案1】:

试试这个你可以给页面 RequisicoesEmAberto.xhtml W.r.t 的参考。仪表板.xhtml

<p:commandButton icon="fal fa-folder-open" iconPos="top" value="Requisições em Aberto" action="../compras/requisicao/RequisicoesEmAberto.xhtml?faces-redirect=true"/> 

【讨论】:

  • 感谢您的回复,我试过这个之前没有用。
猜你喜欢
  • 1970-01-01
  • 2016-02-21
  • 2016-01-13
  • 2014-10-18
  • 2010-11-01
  • 2013-06-26
  • 1970-01-01
  • 2012-02-05
  • 1970-01-01
相关资源
最近更新 更多