Image byte [] to response.outputStream in Grails leads to “Cannot forward after response has been committed”

帅比萌擦擦* 提交于 2019-11-29 16:08:32
Igor Artamonov

Grails don't know that you've already processed response, and if you aren't returning anything grails tries to apply default logic.

Put

return null

at the end of your action.

The error you are showing has to do with at what point the code you posted gets executed. The exception says

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

An HttpServletResponse is typically committed, ie. the headers are sent, when you start writing to its OutputStream. At this point you cannot change the headers or status code and you cannot use a RequestDispatcher to forward() the request to another resource.

Check if you are doing any of these things.

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