0

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

http://localhost:9080/staticWebRoot/logout.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>
4

1 回答 1

2

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

只需使用ExternalContext#redirect().

public void redirect() throws IOException {
    // ... 
    FacesContext.getCurrentInstance().getExternalContext().redirect("/staticWebRoot/logout.xhtml");
}
于 2013-08-23T20:22:03.217 回答