后台返回文件流方式,前端采用form表单 action 属性赋值流。代码submit提交.
前端代码如下:
<form id="download" action='' method='post'/>
</form>
$("#download").attr("action", url);
//触发submit事件,提交表单
$("#download").submit();
后台java 代码如下
response.reset();标签:文件,前端,submit,ouputStream,html,download,response From: https://www.cnblogs.com/libing029/p/17851179.html
response.setContentType("application/vnd.ms-excel");//excel表格
response.setHeader("Content-disposition", "attachment;filename=" +
new String((filename + 后缀名).getBytes(),
"iso-8859-1"));
OutputStream ouputStream = response.getOutputStream();
wb.write(ouputStream);
ouputStream.flush();
ouputStream.close();