http://blog.csdn.net/nohero1/article/details/41476855
方法有两种:
比较优雅的
- @RequestMapping("/export")
- public ResponseEntity<byte[]> export() throws IOException {
- HttpHeaders headers = new HttpHeaders();
- headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);
- headers.setContentDispositionFormData("attachment", "dict.txt");
- return new ResponseEntity<byte[]>(FileUtils.readFileToByteArray(new File("C:/Users/Administrator/Desktop/a.txt")),
- headers, HttpStatus.CREATED);
- }