OutputStream os = response.getOutputStream();
try {
response.setHeader("Content-Disposition", "attachment; filename="+name);
if(contentType.equals(".doc"))
{
response.setContentType("application/msword");
}
if(contentType.equals(".pdf"))
{
response.setContentType("application/pdf");
}
os.write(FileUtils.readFileToByteArray(new File(path)));
os.flush();
} finally {
if (os != null) {
os.close();
}
}
可以实现下载,并且文件大小一样,但是打不开