太长,没时间看.
给你个参考!
sendRedirect ()错误例子
Note:在servlet里面,如果已经有一个response返回给客户端,在这个response里就不能再跟sendRedirect(),不然会产生一个IllegalStateException错误,比如:
PrintWriter pw = res.getPrintWriter();
pw.println("<html><body>Hello World!</body></html>");
pw.flush(); //Sends the response
res.sendRedirect("http://www.cnn.com"); //Tries to redirect
这样就会引发错误。
给你个参考!
sendRedirect ()错误例子
Note:在servlet里面,如果已经有一个response返回给客户端,在这个response里就不能再跟sendRedirect(),不然会产生一个IllegalStateException错误,比如:
PrintWriter pw = res.getPrintWriter();
pw.println("<html><body>Hello World!</body></html>");
pw.flush(); //Sends the response
res.sendRedirect("http://www.cnn.com"); //Tries to redirect
这样就会引发错误。
可是,为什么同样的代码,在以链接方式请求时,没有这个异常,可以action-post方式请求时就有呢?