代码: String fileDisplayName = fileFullName.substring(fileFullName.lastIndexOf("\\") + 1);
InputStream is = null;
OutputStream os = null;
try {
response.setContentType("application/x-download");
response.addHeader("Content-Disposition", "attachment;filename="+ fileDisplayName);
os = response.getOutputStream();
is = new FileInputStream(fileFullName);
while ((bytesRead = is.read(buffer)) > 0 ) {
os.write(buffer, 0, bytesRead);
}
os.flush();
log.info(user.getId() + "������" + fileDisplayName);
} catch (IOException e) {
log.error(e);
} finally {
try {
if (is != null) {
is.close();
}
} catch (IOException e) {
log.error(e);
}
} 红色为报错那句。