我正在尝试导航到静态Web项目中的xhtml页面。我的原始上下文是一个带有icefaces 3.3的动态Web项目。即使我在.faces
中将.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>
答案 0 :(得分:2)
您可以而且不应该对非JSF资源使用导航规则。 JSF假设所有to-view-id都是当前webapp中的真实JSF视图(否则,它们首先不会被称为“视图ID”)。
只需使用ExternalContext#redirect()
。
public void redirect() throws IOException {
// ...
FacesContext.getCurrentInstance().getExternalContext().redirect("/staticWebRoot/logout.xhtml");
}