2 <jsp:forward page="" />
兩區別:1.此語句前不允許有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的操作已經無意義了;
如果要跳到相同主機下,此語句后面的語句執行完成后才會跳轉;
2.<jsp:forward page="" />
此語句前不允許有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)
...
跳轉后瀏覽器地址欄不變,但是只能跳到當前主機下
此語句后面的語句執行完成后才會跳轉
不過這方法可以隱藏地址欄不變.在有些情況下可能要用到...