spring读写excel文件的时候,return语句或者异常信息写到了文件里面
来源:互联网 发布:做地图的软件 编辑:程序博客网 时间:2024/06/06 01:14
spring读写excel文件的时候,return语句或者异常信息写到了文件里面
return 语句
if(true) { System.out.println("准备返回了"); return "hellowrld";}response.addHeader("Content-Disposition", "attachment;fileName=ddd.xls");// 设置文件名
只要是在设置header的Content-Disposition 属性之前, return 语句的内容都会被写到excel中。
异常
try { wwb.write(); wwb.close(); if(true) { System.out.println("准备抛异常了"); throw new RuntimeException("hellowrld"); } } catch (IOException e) { e.printStackTrace(); } catch (WriteException e) { e.printStackTrace(); }
WritableWorkbook 实例close之后抛异常,不会影响文件下载。
try { wwb.write(); if(true) { System.out.println("准备抛异常了"); throw new RuntimeException("hellowrld"); } wwb.close();} catch (IOException e) { e.printStackTrace();} catch (WriteException e) { e.printStackTrace();}
WritableWorkbook 实例close之前抛异常,文件不能下载,服务器直接抛异常。
try-catch-finally
try-catch块中有 return , 或者 抛异常以后 , 如果有finally, 则finally必会执行,可以处理我们自己抛出的异常,以及关闭流。
阅读全文
0 0
- spring读写excel文件的时候,return语句或者异常信息写到了文件里面
- 托管里面的web请求,异常处理,读写文件。
- 由OutOfMemoryException异常到Excel的Xlsx文件读写
- jxl包实现对Excel文件的写读写操作
- 异常处理的时候finally语句中return注意点
- 由写sql语句的.xml文件引起的异常
- Unity-Excel文件的读写
- Unity读写资源包里面的文件
- python里面对文件的读写操作
- 关于POI或者JXL读写EXCEL文件的总结,由浅及深(一)
- 输入详细异常信息到log文件里面
- EXCEL文件的SQL语句
- 写类文件时候版本版权信息格式
- ria 里面的写文件例子
- 读写Excel文件
- POI读写Excel文件
- POI读写Excel文件
- POI读写Excel文件
- LeetCode 387 First Unique Character in a String
- 初接触Directdraw
- mybatis useGeneratedKeys = "true"
- 71-75.个人练习。
- LeetCode 541 reverse string 2
- spring读写excel文件的时候,return语句或者异常信息写到了文件里面
- leetCode刷题归纳-backtracking(39. Combination Sum I && II)
- SpringMVC Ajax上传文件实例
- $.fn
- 理解build.gradle文件
- Search a 2D Matrix
- Numpy中矩阵对象(matrix)
- 信号量
- C语言的头文件详解