【问题标题】:Navigation Case extension导航案例扩展
【发布时间】:2013-08-23 19:23:39
【问题描述】:

我正在尝试导航到静态 Web 项目中的 xhtml 页面。我原来的上下文是一个带有icefaces 3.3 的动态网络项目。即使我在to-view-id 中指定.xhtml 作为结果,它也会使用.faces 重定向到以下路径。有没有办法让它重定向到.xhtml

http://localhost:9080/staticWebRoot/logout.faces

faces-navigation.xml

<navigation-rule>
    <from-view-id>*</from-view-id>
    <navigation-case>
    <from-outcome>logout</from-outcome>
    <to-view-id>/../../staticWebRoot/logout.xhtml</to-view-id>
    <redirect/>     
    </navigation-case>
</navigation-rule>

【问题讨论】:

    标签: jsf jsf-2 websphere-7 icefaces-3


    【解决方案1】:

    您可以也不应该对非 JSF 资源使用导航规则。 JSF 假定所有 to-view-id 都是当前 web 应用程序中的真实 JSF 视图(否则,它们一开始就不会被称为“视图 ID”)。

    只需使用ExternalContext#redirect()

    public void redirect() throws IOException {
        // ... 
        FacesContext.getCurrentInstance().getExternalContext().redirect("/staticWebRoot/logout.xhtml");
    }
    

    【讨论】:

    • 这个答案有效,但是当我使用 JSF 1.2 和 Icefaces 1.8 时,为什么问题中的导航规则可以正常工作?我只是想知道 JSF 2.1 中是否引入了一些更改
    猜你喜欢
    • 2021-03-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-09-25
    • 2015-06-10
    • 1970-01-01
    • 2021-11-19
    相关资源
    最近更新 更多