自己总结的java.lang.IllegalStateException错误

java.lang.IllegalStateException: Cannot forward after response has been committed

网上都说什么加一个return 有用全是放屁

是你的dopost方法里面由于response多次提交或者是由于有页面显示后仍然含请求转向产生的,

就是说程序在return之前就已经执行了跳转或者执行过response,之后遇到return的话,程序想再次执行跳转,也就是重定向,

实际上是

	@Override
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		super.doPost(request, response);
request.getRequestDispatcher("message.jsp").forward(request, response);

  里的super.dopost 和 forward 有冲突

super里重定向一次, forward重定向一次 造成了 两个跳转

所以产生了java.lang.IllegalStateException: Cannot forward after response has been committed

原文地址:https://www.cnblogs.com/li-print/p/3472176.html