问题
String contenttype = rs.getString("contentType");
String filename = rs.getString("fileName");
response.setContentType(contenttype);
response.setHeader("Content-disposition","attachment;filename=" + filename.replace('"', ' '));
java.io.InputStream instream = rs.getBinaryStream("fileData");
byte[] b = new byte[1000];
while (instream.read(b) > 0) {
try {
response.getOutputStream().write(b);
}
catch(Exception e) {}
}
try {
response.getOutputStream().flush();
}
catch(Exception e) {}
回答1:
Normally, it should allow calling response.getOutputStream() any number of times. I think you are calling both response.getOutputStream() and response.getWriter().
Please check if you are calling response.getWriter() anywhere or is the request is landing in JSP which writes to response.getWriter().
来源:https://stackoverflow.com/questions/10512179/ava-lang-illegalstateexception-getoutputstream-has-already-been-called-for-th