getOutputStream() has already been called for this response solution

The reason for the exception: There is out.write("") in the servlet code generated by the web container, which conflicts with the response.getOutputStream() called in the JSP. That is, the Servlet specification states that it is not possible to call both response.getOutputStream() and call response.getWriter(), no matter which one is called first, IllegalStateException should be thrown when calling the second one, because in jsp, the out variable is actually obtained through response.getWriter, and your program uses both response. getOutputStream uses the out variable again, so the above error occurs.

1. Jsp solution , add at the end of the program:

out.clear();
out = pageContext.pushBody();

2. The Struts2 solution
directly returns null from the processing method in the action, and the problem is solved! ! !

 

Original address: http://www.cnblogs.com/linjiqin/p/3148091.html

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326505701&siteId=291194637