对我的代码允许用户下载文件的任何评论。最佳做法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);
}
大多数时候,我没有得到低于错误。但有一次,我得到错误
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)
您声明这与tapestry有关,但是在您的问题中没有提及任何tapestry。请解释这是如何挂毯相关或删除标签。 – pstanton 2010-11-29 04:04:45
挂毯服务 – cometta 2010-11-29 04:06:46