Spring mvc about IE to Application/json Content-type does not support the solution---Duang solves the

Source: Internet
Author: User

In modern web development, we use asynchronous development for the user's experience, the user can not see the actual execution of the background, only care about the result, so good message determines the attitude of the system to the user, so to develop a set of standard prompt message, I chose JSON, but in the actual development process, Will find IE does not support the Application/json type, so I also found on the internet a lot of the same problem, but most of the statements are registered registry, but our door publishing system can not let each user register the registry, which is obviously unreasonable, so I found that You can fix the problem by simply modifying the type of content returned (ContentType).

1, by default, we will use Spring MVC's own annotation @responsebody to return processing results, but @responsebody defaults to the result of processing as Application/json, which leads to the inability of IE to parse, Instead, you are prompted to download a file with a "file name. JSON" That is not understandable to the user, so in order to give the user a unified and good experience, use the following method two.

2, use Response.setcontenttype ("Text/html;charset=utf-8"); Response.getwriter (). Print (Map_obj_result.get ("result") ), instead of the system default Application/json, this can be a perfect solution to the problem of JSON is not supported under IE.

In the multi-browser compatibility issue There are many ways to go, there are a lot of problems to solve, so to ensure a calm heart, you can calm the problem, in fact, the problem is not difficult, difficult is how to ensure a cool heart.

Spring mvc about IE to Application/json Content-type does not support the solution---Duang solves the

Related Article

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.