|
@@ -50,13 +50,15 @@ public class DownloadController {
|
|
|
resp.reset();// 清空输出流
|
|
|
resp.setCharacterEncoding("UTF-8");
|
|
|
// resp.setHeader("Content-disposition", "attachment; filename=" + resultFileName);
|
|
|
+// resp.setContentType("application/txt");
|
|
|
resp.setHeader("Content-Length", String.valueOf(resourceAsStream.available()));
|
|
|
- resp.setContentType("application/txt");
|
|
|
+ resp.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
|
|
+ resp.setHeader("Content-disposition", "attachment;filename=" + fileName);
|
|
|
out = resp.getOutputStream();
|
|
|
int len;
|
|
|
- byte[] buffer = new byte[1024]; //缓冲区
|
|
|
- while ((len = inputStream.read(buffer)) != -1) { //将接受的数据写入缓冲区数组buffer
|
|
|
- out.write(buffer, 0, len); //将缓冲区buffer写入byte数组输出流
|
|
|
+ byte[] buffer = new byte[1024];
|
|
|
+ while ((len = inputStream.read(buffer)) != -1) {
|
|
|
+ out.write(buffer, 0, len);
|
|
|
}
|
|
|
out.flush();
|
|
|
} catch (Exception e) {
|