当我使用error.html它时,它将重定向到error.xhtml,而不是error.html.我可以在ManagedBean中重定向到html error.xhtml吗?
导航案例结果被视为JSF视图.因此它始终需要JSF视图.如果由于某些不明原因而无法重命名error.html为error.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)
| 归档时间: |
|
| 查看次数: |
1308 次 |
| 最近记录: |