OutputStream output; try { output = response.getOutputStream(); //清空缓存 response.reset(); //定义浏览器响应表头,顺带定义下载名,比如students(中文名需要转义) String s = file.getName() + file.getBirthday(); response.setHeader("Content-disposition", "attachment;filename=" + new String(s.getBytes(), "iso-8859-1") + ".xls"); //定义下载的类型,标明是excel文件 response.setContentType("application/vnd.ms-excel"); //这时候把创建好的excel写入到输出流 wb.write(output); //养成好习惯,出门记得随手关门 output.close(); } catch (IOException e) { e.printStackTrace(); }
java实现通过浏览器下载文件
免责声明:文章转载自《java实现通过浏览器下载文件》仅用于学习参考。如对内容有疑问,请及时联系本站处理。
上篇ubuntu16.04里如何正确添加用root用户来登录图形界面(图文详解)Oracle去除重复(某一列的值重复),取最新(日期字段最新)的一条数据下篇
宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=