Question

I am using valums file-uploader to upload files. This works great if my Spring controller returns void. If I add a @Responsebody Object to my controller IE things that I am about to download instead of uploading a file and launches a dialog.

The reason I would like to have a @Responsebody Object and not void is for error handling. How can I trick IE in this case?

Was it helpful?

Solution

I'm assuming that Spring is automagically setting the content-type to application/json for you, which will not work in IE. Ensure the content-type of your response is text/plain. Some will say that text/html is correct, and that is true for most cases. However, text/html will cause you problems if your JSON response contains HTML as IE will mess with the response. So, your safest bet is to ensure the content-type of your response is text/plain.

While we are on the topic of IE quirkiness, also be sure that you only return a 200 response if you intend to also include JSON in your response. IE will, by default, replace the content of "small" non-200 responses with a "friendly" message. "Small", I believe, is defined as a response that is less than 512 (or possibly 256) bytes.

For a list of all things you should be aware of when using IE, have a peek at the "limitations of IE" section in the Fine Uploader readme.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top