Spring: getOutputStream() has already been called for this response

爷,独闯天下 提交于 2019-11-28 13:03:25
Jorge_B

If you return 'test', you are instructing your controller to send you to some view... after using the response outputStream to return a binary file. Here is an idea of how you should manage this:

Downloading a file from spring controllers

I just experienced this problem.

The problem was caused by my controller method attempting return type of String (view name) when it exits. When the method would exit, a second response stream would be initiated.

Changing the controller method return type to void resolved the problem.

I hope this helps if anyone else experiences this problem.

mo sean

If you want to send String then you could change

return "test";

to

return null;
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!