此语句前不允许有out.flush(),如果有,会有异常: java.lang.IllegalStateException: Can't sendRedirect() after data has committed to the client. at com.caucho.server.connection.AbstractHttpResponse.sendRedirect(AbstractHttpResponse.java:558) ... 跳转后浏览器地址栏变化 如果要跳到不同主机下,跳转后,此语句后面的语句会继续执行,如同新开了线程,但是对response的操作已经无意义了; 如果要跳到相同主机下,此语句后面的语句执行完成后才会跳转; 二. response.setHeader("Location","")
此语句前不允许有out.flush(),如果有,会有异常: java.lang.IllegalStateException: forward() not allowed after buffer has committed. at com.caucho.server.webapp.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:134) at com.caucho.server.webapp.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:101) at com.caucho.jsp.PageContextImpl.forward(PageContextImpl.java:836) ... 跳转后浏览器地址栏不变,但是只能跳到当前主机下 此语句后面的语句执行完成后才会跳转