Issues with flash upload in spring MVC

Source: Internet
Author: User

Reprint Please specify: theviper http://www.cnblogs.com/TheViper

Uploading on the PC side, often for compatibility, uses Flash (such as swfupload,uploadify) for a better user experience.

However, if the background is spring MVC and the browser is IE, the server will not return data to flash, triggering the Filereference dataevent.upload_complete_data event, the execution callback to the page corresponding changes. Oddly, in non-IE browsers, Flash will be able to get the data returned.

Change the log4j level to debug.

Ie

Non-IE

Can see two have received flash sent over the multipart file content, but IE debug has a httpmediatypenotacceptableexception. The document says exception thrown when the request handler cannot generate a response it's acceptable by the client. This will understand that the response returned in the background is not accepted by Flash.

So how did this problem come out?

Fortunately, flash upload in this cock node JS background can be run. The following is a look under IE Flash upload request header information.

And not under IE

Notice the IE head of the message inside the Accept: ' text/* '. This dick's spring MVC background returns JSON. and the most direct way. @RequestMapping (value= "/upload1", produces {"Application/json;charset=utf-8"}). In other words, the response is content-type:application/json;charset=utf-8. And then Flash only accepts content-type:text/* (Text/html,text/xml ...) The response. Non-IE header information is */*, can accept content-type for any type of response, Flash can of course accept the background response.

Know the problem where it is good to change, Ben here directly to the Application/json to text/*. If you return JSON or other forms of data in another way, be careful to set the response Content-type to match the Flash's accept. The concrete of this cock will not say.

In addition, if you modify the Flash source code, upload urlrequest Modify accept is useless, upload the time accept or flash in different browser default values.

            var request:urlrequest=New urlrequest (' http://localhost:8080/qzone/photo/upload1 '  );             var New Urlrequestheader ("Accept""Application/json");            Request.requestHeaders.push (header);

Issues with flash upload in spring MVC

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.