報錯:java.net.SocketException: Socket closed 代碼:String filename = "xxx報表"+TimeUtil.getCurrentTime()+".xls";try {filename = new String(filename.getBytes("GBK"), "ISO-8859-1");} catch (UnsupportedEncodingException e) {logger.error("下載異常");}response.addHeader("Content-Disposition", "attachment;filename="+filename);response.setContentType("application/octet-stream");OutputStream outputStream = null;try {outputStream = response.getOutputStream();// wb 是一個excel對象來的,已經(jīng)有內(nèi)容wb.write(outputStream);outputStream.flush();outputStream.close();} catch (IOException e) {downloadResult = false;logger.error("下載報表異常:",e);}finally{……省略……}
1 回答

婷婷同學_
TA貢獻1844條經(jīng)驗 獲得超8個贊
這個異常一般是超時等把連接關掉了,此時寫socket就會出現(xiàn)問題
可以服務端保存成文件,返回前端的是連接地址,這樣就不會有問題了
添加回答
舉報
0/150
提交
取消