问题
for a web application builded on struts and jsp technologies , i 'm looking for a good example wich explains how to download files from the server side
回答1:
i manage to do it with this few lines of code : just add this to your action :
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();
来源:https://stackoverflow.com/questions/12107909/best-download-file-with-struts-1-1-method