如何在jsf中重定向html?

Caa*_*gok 1 navigation jsf

当我使用error.html它时,它将重定向到error.xhtml,而不是error.html.我可以在ManagedBean中重定向到html error.xhtml吗?

Bal*_*usC 6

导航案例结果被视为JSF视图.因此它始终需要JSF视图.如果由于某些不明原因而无法重命名error.htmlerror.xhtml(请记住,您可以在Facelets页面中安全地使用纯HTML),那么您需要自己使用重定向向非JSF资源发送ExternalContext#redirect().

public void someAction() throws IOException {
    // ...

    ExternalContext ec = FacesContext.getCurrentInstance().getExternalContext();
    ec.redirect(ec.getRequestContextPath() + "/error.html");
}
Run Code Online (Sandbox Code Playgroud)