ユーザーがファイルをダウンロードできるようにするための私のコードに関するコメント。ベストプラクティスresponse.getOutputStream
if(fileObject !=null)
response.setHeader("Content-disposition", "attachment; filename=\""+fileObject.getFilename()+"\"");
response.setContentType(fileObject.getFiletype());
response.setContentLength((int)fileObject.getFilesize().intValue());
try {
if(response !=null && response.getOutputStream() !=null &&fileObject!=null && fileObject.getBinData() !=null){
OutputStream out = response.getOutputStream();
out.write(fileObject.getBinData());
}
} catch (IOException e) {
throw new ApplicationRuntimeException(e);
}
ほとんどの場合、私は以下のエラーにはなりません。しかし、一度、しばらく、私はあなたが二回response.getOutputStream()
を呼び出しているエラー
29 Nov 2010 10:50:41,925 WARN [http-2020-2] - Unable to present exception page: getOutputStream() has already been called for this response
java.lang.IllegalStateException: getOutputStream() has already been called for this response
at org.apache.catalina.connector.Response.getWriter(Response.java:610)
あなたはこれがタペストリーと関係があると述べていますが、あなたの質問ではタペストリーへの言及はありません。これがタペストリーにどのように関連しているか説明してください。 – pstanton
タペストリーサービス – cometta