当前位置:网站首页>【浏览器打开导出的excel】
【浏览器打开导出的excel】
2022-08-08 20:56:00 【阳光下奔跑的小孩儿】
public void setResponseHeader(HttpServletResponse response,String filePath) {
try {
File file = new File(filePath);
String filename = file.getName();
if( !file.exists()){
return;
}
response.reset();
FileInputStream fileInput = new FileInputStream(file);
OutputStream outPut = response.getOutputStream();
byte[] buffer = new byte[1024];
int len;
while ((len = fileInput.read(buffer)) > 0){
outPut.write(buffer, 0, len);
}
fileInput.close();
response.addHeader("Content-Disposition", "attachment;filename=" +new String(filename.getBytes("UTF-8"), "utf-8"));
response.addHeader("Content-Length", "" + file.length());
response.setContentType("application/x-msdownload");
} catch (IOException ex) {
ex.printStackTrace();
return;
}
}
边栏推荐
猜你喜欢
Flask 教程 第七章:错误处理
目标检测论文 Few-Shot Object Detection with Attention-RPN and Multi-Relation Detector
我们仍未知道那天踩的MultipartFile file为null的大坑是为什么
Flask 教程 第八章:粉丝
知乎高赞:如果一个程序员工作5年后还没成为大牛,是不是该考虑别的路子了?
第十三届蓝桥杯(Web 应用开发)线上模拟赛【第九题】(知乎首页数据动态化)
Use fontforge to modify font, keep only numbers
编译原理——LL1分析程序实验(C#)
目标检测论文 Precise detection of Chinese characters in historical documents with DRL
Flask 教程 第一章:Hello, World!
随机推荐
window下socket(TCP)控制台程序
第十三届蓝桥杯(Web 应用开发)线上模拟赛【第十题】(RESTful API 开发)
利用shell脚本同时编译生成多个cmake工程
Flask 教程 第四章:数据库
常见的病毒(攻击)分类
简单Swing界面笔记
Gradle简单到使用kotlin编写到常用命令
Questions about Mac terminal custom commands and Mysql command
Kotlin之JSON格式解析
jmeter简单压测
源码分析MyCat专栏
PHP使用glob()查找文件
基于opencv的实时睡意检测系统
sudo控制用户权限实战操作
手机投影到deepin
Kotlin中IO流
Simple Swing interface notes
Everything原理探究以及C#实现
Redis Bloom Filter
解决gradle导包速度慢问题