Cannot call sendRedirect()/forward after the response has been committed的问题

问题其实已经很明确了,说明就是不能重定向,因为已经有response了。

然后一检查,是前面已经用servlet的printWriter打印东西了。

所以,重定向前

必须先保证没有任何的输出,包括:
1、Cookie;
2、resp.getWriter()写文本信息;
3、已经发送过重定向。


重点检查下这些问题吧,如果你写了Filter,或者Servlet已经做过forward,也要注意看看。

原文地址:https://www.cnblogs.com/wangshen31/p/8344412.html