标签:style blog http color 文件 os
@RequestMapping("download") public ResponseEntity<byte[]> download(Long fileKey) throws IOException { HttpHeaders headers = new HttpHeaders(); String fileName=new String(massMessage.getFileName().getBytes("UTF-8"),"iso-8859-1"); headers.setContentDispositionFormData("attachment", fileName); headers.setContentType(MediaType.APPLICATION_OCTET_STREAM); byte[] data = new byte[2];//要下载的数据流 return new ResponseEntity<byte[]>(data, headers, HttpStatus.CREATED); }
下载时提示:
下载时提示ie无法打开该站点,请求的站点不可用或找不到
类似信息
修改为下面的就OK了,主要是HttpStatus.CREATED修改为HttpStatus.OK
原因是IE 不支持201的状态码,修改为200就行了
@RequestMapping("download") public ResponseEntity<byte[]> download(Long fileKey) throws IOException { HttpHeaders headers = new HttpHeaders(); String fileName=new String(massMessage.getFileName().getBytes("UTF-8"),"iso-8859-1"); headers.setContentDispositionFormData("attachment", fileName); headers.setContentType(MediaType.APPLICATION_OCTET_STREAM); byte[] data = new byte[2];//要下载的数据流 return new ResponseEntity<byte[]>(data, headers, HttpStatus.OK); }
Spring MVC 文件下载时候 发现IE不支持,布布扣,bubuko.com
标签:style blog http color 文件 os
原文地址:http://www.cnblogs.com/ranger2016/p/3842274.html