下载文件时保存为jsp对话框...如何提示用户保存,查看取消对话框,而不是直接打开图像 [英] downloading file with save as dialog box in jsp...how to prompt user for save,view cancel dialog instead of directly opening image
问题描述
只要用户点击链接,就可以直接打开文档。
>我想要显示一个对话框(通常出现在很多网站上),这个对话框会要求用户保存,取消和查看文档。
任何人都可以帮我解决问题。
我在我的控制器类中使用下面的代码:
InputStream is = new FileInputStream(new File(** File Path **);
IOUtils.copy(is,response.getOutputStream()) ;
response.flushBuffer();
我得到了解决方案。
我添加了响应内容类型,它正在工作。
response.setHeader(Content -disposition,attachment; filename = abc.jpg);
感谢所有试图帮助我解决这个问题的人。
I am having one jsp in which i have provided one link for downloading any document.
Whenever user clicks the link,it directly open the document.
I want to show one dialog box(which generally appears on many websites) which will ask user to save, cancel and view the document.
can anybody help me out..??
i am using following code in my controller class.
InputStream is = new FileInputStream(new File(**File Path**);
IOUtils.copy(is, response.getOutputStream());
response.flushBuffer();
I got the solution .
I added response content type and it's working.
response.setHeader("Content-Disposition", "attachment;filename=abc.jpg");
Thanks to all who tried to help me out from this issue.
这篇关于下载文件时保存为jsp对话框...如何提示用户保存,查看取消对话框,而不是直接打开图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!