IE对http1.1 不支持201状态码
来源:互联网 发布:西恩潘 知乎 编辑:程序博客网 时间:2024/05/22 02:16
最近用spring MVC做一个文件下载程序的时候,发现IE对HttpStatus.CREATED状态的并非完全支持
如:
@RequestMapping(value = "/download", method = RequestMethod.POST )@ResponseBodypublic ResponseEntity<byte[]> download(@RequestParam("fileName") String fName) throws IOException {System.out.println(fName);String path = this.servletContext.getRealPath("/WEB-INF/load") + "\\aaa\\" + fName;System.out.println(path);HttpHeaders headers = new HttpHeaders();headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);headers.setContentDispositionFormData("attachment", new String(fName.getBytes("GBK"),"ISO8859-1"));File file = new File(path);if(file.exists()){return new ResponseEntity<byte[]>(FileUtils.readFileToByteArray(file), headers,HttpStatus.CREATED);}headers.setContentDispositionFormData("attachment", "error.txt");return new ResponseEntity<byte[]>("发送错误.".getBytes(), headers,HttpStatus.CREATED);}
在IE中并不能下载,而在其他浏览器是可以下载的,但是下面的代码却可以
@RequestMapping(value = "/download", method = RequestMethod.POST )@ResponseBodypublic ResponseEntity<byte[]> download(@RequestParam("fileName") String fName) throws IOException {System.out.println(fName);String path = this.servletContext.getRealPath("/WEB-INF/load") + "\\aaa\\" + fName;System.out.println(path);HttpHeaders headers = new HttpHeaders();headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);headers.setContentDispositionFormData("attachment", new String(fName.getBytes("GBK"),"ISO8859-1"));File file = new File(path);if(file.exists()){return new ResponseEntity<byte[]>(FileUtils.readFileToByteArray(file), headers,HttpStatus.OK);}headers.setContentDispositionFormData("attachment", "error.txt");return new ResponseEntity<byte[]>("发送错误.".getBytes(), headers,HttpStatus.OK);}
所以我认为是IE对201状态码的支持问题,不知道有没有其它解决方法,希望有解决此问题的大师指导。
0 0
- IE对http1.1 不支持201状态码
- IE对http1.1 不支持201状态码(待确定)
- http1.1状态码
- HTTP1.1状态码
- HTTP1.1状态码
- HTTP1.0和HTTP1.1区别及http状态码
- HTTP1.1常见状态码说明
- Http1.1特定的状态码
- HTTP1.1 连接,方法,状态码
- HTTP1.1应答状态
- Http1.0和Http1.1的区别和部分状态码
- HTTP1.1比HTTP1.0增加的新的状态码
- HTTP状态码含义、HTTP1.0和HTTP1.1的区别
- IE/Firefox HTTP1.1协议设置
- http1.1状态代码及其说明
- HTTP1.1 状态代码及其含义
- HTTP1.1状态代码及其含义
- HTTP1.1状态代码及其含义
- 电力系统找工作经验分享--送与电气的师弟师妹们
- Android_常见度量单位【xdpi、hdpi、mdpi、ldpi】解读
- 哪位大侠能帮忙把这个关于pdf解析的代码优化下,有报酬
- 《大话设计模式》 -- 14.抽象工厂模式
- JDK环境变量设置详解
- IE对http1.1 不支持201状态码
- C++的64位整数[原]by 赤兔
- 《汇编语言》王爽版重点摘要-----第五章
- Android NDK开发(2)----- JNI多线程
- jstat命令用法
- STL之map容器
- HDU4442
- ZOJ 3261 Connections in Galaxy War 并查集
- LPC1788 EMWIN