设置response的Header使得Chrome浏览器打开PDF而不自动下载

关键代码

response.setContentType("application/pdf");
response.setHeader("Content-Disposition", "inline;fileName=XXXX.pdf");

其中比较关键的是Content-Disposition是inline而不是attachment,这样提示浏览器来显示文档而不是下载

posted @ 2017-05-04 11:04  weiwei5987  阅读(9094)  评论(0编辑  收藏  举报