If you want to force pop up "Save File" dialog to ask user save file from server.
We need to set the several parameter to response.
the first is content type.
response.setContentType("application/pdf"); // the type is the file type you want to user to save.
Another is content disposition.
This is very important when you want to force the save dialog. not matter if the browser has assicate some file type to open in the browser.
response.setHeader("Content-Disposition", "attachment;filename=/"somename/"");
Notice: attachment is very important here since it's force prompt the save file dialog.
本文介绍如何通过设置服务器响应参数来强制浏览器弹出“保存文件”对话框,而不是直接打开文件。关键在于设置正确的ContentType和Content-Disposition头部信息。
5110

被折叠的 条评论
为什么被折叠?



