1 回答

TA貢獻(xiàn)1775條經(jīng)驗(yàn) 獲得超8個贊
Location
客戶端發(fā)送HTTP請求到 somepage.xhtml
.服務(wù)器將HTTP響應(yīng)發(fā)送回 Location: newpage.xhtml
標(biāo)頭 客戶端發(fā)送HTTP請求到 newpage.xhtml
(這反映在瀏覽器地址欄中!) 服務(wù)器發(fā)送HTTP響應(yīng),內(nèi)容為 newpage.xhtml
.
客戶端發(fā)送HTTP請求到 somepage.xhtml
.服務(wù)器發(fā)送HTTP響應(yīng),內(nèi)容為 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()
另見:
添加回答
舉報