JSF中的导航有什么区别
FacesContext context = FacesContext.getCurrentInstance();
context.getApplication().getNavigationHandler().handleNavigation(context, null, url);
Run Code Online (Sandbox Code Playgroud)
和重定向
HttpServletResponse response = (HttpServletResponse) FacesContext.getCurrentInstance().getExternalContext().getResponse();
response.sendRedirect(url);
Run Code Online (Sandbox Code Playgroud)
以及如何决定何时使用什么?
导航问题是页面URL不会更改,除非faces-redirect=true添加到导航URL的查询字符串中.但是,在我的情况下,faces-redirect=true如果我想重定向到像纯HTML页面这样的非JSF页面,则会附加throws错误.
另一种选择是BalusC在JSF 2.0重定向错误中提出的建议