java.lang.IllegalStateException: Cannot call sendRedirect() after the response has been commi

来源:互联网 发布:知乎为什么垃圾 编辑:程序博客网 时间:2024/06/05 11:14

HTTP Status 500 - Cannot call sendRedirect() after the response has been committed

主要是 sendRedirect()执行完之后没有结束,还会继续往下执行,所以sendReirect()后面就不要在sendReirect()了。


if(type.equals("0")){
...
response.sendRedirect("cart.jsp");}else if(type.equals("1")){
...
response.sendRedirect("cart.jsp");}else if(type.equals("2")){...response.sendRedirect("cart.jsp");}else if(type.equals("3")){...response.sendRedirect("success.jsp");}response.sendRedirect("index.jsp");


要么每次sendRedirect之后return  要么再放个else

0 0
原创粉丝点击