3 回答

TA貢獻2037條經(jīng)驗 獲得超6個贊
forward()
, sendRedirect()
sendError()
protected void doPost() { if (someCondition) { sendRedirect(); } forward(); // This is STILL invoked when someCondition is true!}
System#exit()
someCondition
true
forward()
sendRedirect()
sendError()
java.lang.IllegalStateException:不能在提交響應后轉發(fā)
if
forward()
sendRedirect()
sendError()
在提交響應后無法調用sendReDirect()
return;
protected void doPost() { if (someCondition) { sendRedirect(); return; } forward();}
protected void doPost() { if (someCondition) { sendRedirect(); } else { forward(); }}
forward()
, sendRedirect()
sendError()
sendError()
setStatus()
forward()
protected void doPost() { out.write("some string"); // ... forward(); // Fail!}
forward()
java.lang.IllegalStateException:不能在提交響應后轉發(fā)
request.setAttribute("data", "some string")
${data}
另見:
不相干

TA貢獻1828條經(jīng)驗 獲得超3個贊
if(!response.isCommitted())// Place another redirection

TA貢獻1853條經(jīng)驗 獲得超18個贊
編輯
getServletConfig().getServletContext() .getRequestDispatcher("/GroupCopiedUpdt.jsp") .forward(request, response);
將數(shù)據(jù)輸出到輸出流,或 事先做了另一次重定向。
添加回答
舉報