文件流输出
这里仅展示Imp
`@Override
public void getFile(LoggingCurve rs, HttpServletResponse response) throws IOException {
Map<String,Object> clum=new HashMap<>();
clum.put("NAME",rs.getName());
// clum.put("NAME",rs.get());
List<LoggingCurve> loggingCurves = baseMapper.selectByMap(clum);
//将你要输出的二进制文件;
byte[] content =loggingCurves.get(0).getContent();//获取对象中的二进制文件,可以getBytes()
// 流输出
response.setCharacterEncoding("utf-8");
//设置强制下载不打开
response.setContentType("application/force-download");
response.addHeader("Content-Disposition", "attachment;fileName=" + rs.getName()+".wis");
// OutputStream os =null;
ServletOutputStream os = response.getOutputStream();
try { //输出字节数组
os.write(content,0,content.length);
os.flush();
} catch ( Exception e) {
throw new RuntimeException("下载失败!");
}finally {
os.close();
}
}
文件流输出
最新推荐文章于 2024-04-20 19:33:09 发布