Spring MVC file download time found IE not supported
@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];//The stream to be downloaded
return new responseentity<byte[]> (data, headers, httpstatus.created);
}
Download prompt:
Prompted IE to not open the site when downloading, the requested site is not available or cannot be found
Similar information
Modify the following to OK, mainly httpstatus.created modified to Httpstatus.ok
The reason is that IE does not support 201 status code, modified to 200 on the line
@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];//The stream to be downloaded return new responseentity<byte[]> (data, headers, Httpstatus.ok); }