If you want to force pop up "Save File" dialog to ask user save file from server.
We need to set the several parameter toresponse.
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.
本文介绍如何通过设置服务器响应参数来强制浏览器显示文件保存对话框,包括设置正确的Content-Type及使用Content-Disposition头来触发保存对话框。
5112

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



