在我的servlet中,我正在使用下面的代码在浏览器中打开一个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();