如何在浏览器中显示PDF文件
在我的servlet中,我使用下面的代码浏览器中打开" title="在浏览器中打开">在浏览器中打开PDF文件,但是,它显示了一个下载对话框。
我做错了什么?
response.setContentType("application/pdf");out = response.getWriter();
String filepath = "D:/MyFolder/PDF/MyFile.pdf";
response.setHeader("Content-Disposition", "inline; filename=" + filepath + ";");
FileOutputStream fileOut = new FileOutputStream("D:/MyFolder/PDF/MyFile.pdf");
fileOut.close();
out.close();
回答:
你可以尝试用
response.setHeader("Content-Disposition", "attachment;filename="+filepath+";");
以上是 如何在浏览器中显示PDF文件 的全部内容, 来源链接: utcz.com/qa/399421.html