1 回答
TA贡献1775条经验 获得超8个赞
Location
客户端发送HTTP请求到 somepage.xhtml
.服务器将HTTP响应发送回 Location: newpage.xhtml
标头 客户端发送HTTP请求到 newpage.xhtml
(这反映在浏览器地址栏中!) 服务器发送HTTP响应,内容为 newpage.xhtml
.
客户端发送HTTP请求到 somepage.xhtml
.服务器发送HTTP响应,内容为 newpage.xhtml
.
somepage.xhtml
RequestDispatcher#forward()
.
HttpServletResponse
sendRedirect()
IllegalStateException
FacesContext#responseComplete()
javax.servlet.*
faces-redirect=true
public String submit() { // ... return "/newpage.xhtml?faces-redirect=true";}
ExternalContext#redirect()
public void listener() throws IOException { // ... ExternalContext ec = FacesContext.getCurrentInstance().getExternalContext(); ec.redirect(ec.getRequestContextPath() + "/newpage.xhtml");}
try-catch
IOException
throws
NavigationHandler#handleNavigation()
public void listener() { // ... FacesContext fc = FacesContext.getCurrentInstance(); NavigationHandler nh = fc.getApplication().getNavigationHandler(); nh.handleNavigation(fc, null, "/newpage.xhtml?faces-redirect=true");}
ExternalContext#redirect()
另见:
添加回答
举报