最近用spring MVC做一个文件下载程序的时候,发现IE对HttpStatus.CREATED状态的并非完全支持
如:
@RequestMapping(value = "/download", method = RequestMethod.POST )
@ResponseBody
public 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&