出力ストリームに直接書き込むアクションがあります。時々私はエラーに次を得る:GroovyPageViewの処理中にエラーが発生しました:この応答に対してgetOutputStream()が既に呼び出されています
Error processing GroovyPageView: getOutputStream() has already been called for this response
Caused by getOutputStream() has already been called for this response
と、この1:
Executing action [getImage] of controller [buddyis.ItemController] caused exception: Runtime error executing action
Caused by Broken pipe
どのように私はこれらの問題を解決することができますか?私が使っている行動は以下の通りです。
注:重要な場合は、Tomcat 7.0.42を使用します。
def getImage() {
byte [] imageByteArray = // some image bytes
response.setHeader 'Content-disposition', "attachment; filename=\"${imageName}${imageExtension}\""
response.setContentType("image/pjpeg; charset=UTF-8")
response.contentLength = imageByteArray.size()
response.outputStream.write(imageByteArray)
response.outputStream.flush()
response.outputStream.close()
return
}
状態コードをインデックス付けまたはレンダリングして、まだ問題が発生していないかどうかを確認してください。あなたは 'render(status:200)'で始めることもできますし、返却の前に少なくとも 'render '完了などで始めることもできます。 – dmahapatro
これはなぜですか? – confile
[この質問](http://stackoverflow.com/questions/13184603/grails-error-using-httpservletresponse-to-export-file-for-download)を参照してください。 – dmahapatro