Spring MVC file download time found IE not supported

Source: Internet
Author: User
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); }

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.