I have a plain HTML page error.html
. When I use
return "error.html?faces-redirect=true";
it will actually redirect to error.xhtml
, not error.html
.
How can I redirect to a non-JSF page in a JSF action method?
I have a plain HTML page error.html
. When I use
return "error.html?faces-redirect=true";
it will actually redirect to error.xhtml
, not error.html
.
How can I redirect to a non-JSF page in a JSF action method?
The navigation case outcome is treated as a JSF view. So it always expects a JSF view. If renaming error.html
to error.xhtml
is not possible for some unclear reason (remember, you can safely use plain HTML in a Facelets page), then you'd need to send a redirect to a non-JSF resource yourself using ExternalContext#redirect()
.
public void someAction() throws IOException {
// ...
ExternalContext ec = FacesContext.getCurrentInstance().getExternalContext();
ec.redirect(ec.getRequestContextPath() + "/error.html");
}