In the project, the open-source jar for operating the Excel file poi is used.
Struts2 container management servlet is used in the project. Instead of simply using Servlet.
Workbook. Write (OS );
OS. Flush ();
OS. Close ();
Return "success ";
In my action, the final output is processed in this way. However, the following error occurs: Java. Lang. illegalstateexception: getoutputstream () has already been called for this response.
This is caused by calls between struts2 methods.
Because: each method returns an action object, while response is the action object parameter,
So it will cause a response conflict!
Therefore, change the final return "success" to return null.
No exception will be reported if it is not managed by sturts2.
The getoutputstream () has already been called for this response error is reported when you use POI in struts2 for Excel download. [go to]