Web应用程序上的支柱和JSP技术建造,我在找一个很好的例子至极解释了如何从服务器端下载文件
Answer 1:
我管理与这个代码几行做到这一点:刚刚添加到您的行动:
OutputStream out = response.getOutputStream();
response.setContentType("application/rtf");
FileInputStream in = new FileInputStream("your_file_path");
byte[] buffer = new byte[4096];
int length;
while ((length = in.read(buffer)) > 0){
out.write(buffer, 0, length);
}
in.close();
out.flush();
文章来源: Best download file with struts 1.1 method