public class ReportBaseAction extends BaseAction {
/**
* serialVersionUID */ private static final long serialVersionUID = 2610690086910318859L;/**
* excel output stream */ protected InputStream csvStream;public String downloadReport() {
try { csvStream = new FileInputStream(getFilePath()); getResponse().setHeader("Content-Disposition", "p_w_upload;filename=" + "REPORT.ZIP");} catch (Exception e) {
e.printStackTrace(); }return SUCCESS;
} public InputStream getCsvStream() { return csvStream; }public void setCsvStream(InputStream csvStream) {
this.csvStream = csvStream; } }struts配置
<action name="downloadReport" method="downloadReport" class="reportBaseAction"> <result name="success" type="stream"> <param name="contentType">application/zip</param> <param name="inputName">csvStream</param> <param name="contentDisposition">p_w_upload;filename="REPORT.ZIP"</param> <param name="bufferSize">4096</param></result> </action> jsp配置 <s:form id="reportForm" action="downloadReport.html" enctype="multipart/form-data" namespace="/report" method="post">