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.xhtmlRequestDispatcher#forward().
HttpServletResponsesendRedirect()IllegalStateExceptionFacesContext#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-catchIOExceptionthrows
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()
另見:
添加回答
舉報
