"Springmvc" "Easyui" about using Easyuiform upload file, return jsonie prompt download file solution!

Source: Internet
Author: User

Let's talk about the environment.

Easyui+springmvc+mybatis

Because by normal means, can not use Ajax to submit a form containing files, so think of using Easyui form to submit, Easyui form encapsulated a set of pseudo-Ajax submission method, so can play the role of the Ajax file form!

However, when the file submitted successfully, back to the back of the background a JSON to prompt the upload success!

But in other browsers are normal, but only in IE will prompt users to download this JSON file!

Look carefully at the next Easyui API to see that there is a passage in the API:

That is, the returned data does not need to set the corresponding type of the return value, but instead returns the JSON-formatted text directly!

So, I set the corresponding type of responsed in the corresponding action

Response.setcontenttype ("Text/html;charset=utf-8")

But the problem is still, and then I open the myeclipse there is a TCPIP port monitoring tool, the corresponding format is empty

This means that the corresponding type of Setup does not work,

Then I remember, I configured the JSON converter in the configuration file.

This sets the corresponding type to JSON, that is, the type of final response is still the JSON type, so

In allowing the corresponding list to add a

Then in the foreground you need to format the returned text as a JSON object in two ways

1,var obj= "(" +data+ ")";

2,var Obj=$.parsejson (data);

And then test the perfect pass, no longer prompted to download the file!

"Springmvc" "Easyui" about using Easyuiform upload file, return jsonie prompt download file solution!

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.