简体   繁体   中英

Download zipped CSV file on client side using Java and struts2

单击按钮后如何下载压缩的CSV文件?

In your Struts Action you need to set the appropriate response headers and then send the file.

  response.setContentType("application/zip");
  response.addHeader("Content-Disposition", 
       "attachment; filename=file.csv.zip");
  IOUtils.copy(zippedCsvFile, response.getOutputStream());

Doing the zip compression on the fly is also an option, as is generating the whole file, of course. If so, you may want to look at DeflaterOutputStream and some library to write CSV data .

这是有关如何使用Struts2下载动态文件的教程

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM