How to force files to open in browser instead of download (pdf)?
其实这是治标不治本的方法,因为之前程序就已经实现了该功能。
response.setHeader("Content-Disposition", "attachment;filename=" +finalFileName);//To have the file downloaded rather than viewed
response.addHeader("Content-Length", "" + file.length());
response.setContentType("application/octet-stream");