Commit fb0cf9d4419ae2d366e6fcae95be30c53db1d231
1 parent
68dd25f5
1
Showing
1 changed file
with
4 additions
and
2 deletions
src/main/java/com/bsth/controller/DownloadController.java
| @@ -31,12 +31,14 @@ public class DownloadController | @@ -31,12 +31,14 @@ public class DownloadController | ||
| 31 | @RequestMapping("download") | 31 | @RequestMapping("download") |
| 32 | public ResponseEntity<byte[]> download(String fileName) throws IOException { | 32 | public ResponseEntity<byte[]> download(String fileName) throws IOException { |
| 33 | fileName = fileName+".xls"; | 33 | fileName = fileName+".xls"; |
| 34 | - String moudelPath = this.getClass().getResource("/").getPath()+ "static\\pages\\forms\\export\\"+fileName; | 34 | + String moudelPath = this.getClass().getResource("/").getPath()+ "static\\pages\\forms\\export\\"+fileName; |
| 35 | + System.out.println(moudelPath); | ||
| 35 | // String path="D:\\export\\target\\"+jName+".xls"; | 36 | // String path="D:\\export\\target\\"+jName+".xls"; |
| 36 | File file=new File(moudelPath); | 37 | File file=new File(moudelPath); |
| 37 | HttpHeaders headers = new HttpHeaders(); | 38 | HttpHeaders headers = new HttpHeaders(); |
| 38 | String realFileName=new String(fileName.getBytes("UTF-8"),"iso-8859-1");//为了解决中文名称乱码问题 | 39 | String realFileName=new String(fileName.getBytes("UTF-8"),"iso-8859-1");//为了解决中文名称乱码问题 |
| 39 | - headers.setContentDispositionFormData("attachment", URLDecoder.decode(realFileName,"utf-8")); | 40 | + headers.setContentDispositionFormData("attachment", URLDecoder.decode(realFileName,"utf-8")); |
| 41 | + System.out.println(realFileName); | ||
| 40 | headers.setContentType(MediaType.APPLICATION_OCTET_STREAM); | 42 | headers.setContentType(MediaType.APPLICATION_OCTET_STREAM); |
| 41 | return new ResponseEntity<byte[]>(FileUtils.readFileToByteArray(file), | 43 | return new ResponseEntity<byte[]>(FileUtils.readFileToByteArray(file), |
| 42 | headers, HttpStatus.CREATED); | 44 | headers, HttpStatus.CREATED); |