Springmvc @RequestBody A workaround for receiving the JSON report HTTP 415 issue

Source: Internet
Author: User
Tags apache tomcat

Now do a project is to do the app server, need to receive JSON request data from the app, the service-side framework is SPRINGMVC, so naturally think of directly using @requestbody to receive JSON data,

The format is as follows:

Public Responseprotocolmap Login (@RequestBody jsonobject requestjson,httpservletrequest request) { Responseprotocolmap responseprotocolmap = null;//Intermediate content omitted ... return responseprotocolmap;}

The first import was Org.json.jar's Org.json.JSONObject package, when requested, there were 415 errors:

HTTP Status 415-type status reportmessagedescription the server refused this request because the request entity was in a F Ormat not supported by the requested resource for the requested method. Apache tomcat/7.0.64

In this issue for a long time to solve the solution, have not found, originally thought SPRINGMVC not support directly receive JSON, and later will be converted into Net.sf.json-lib.jar JSON net.sf.json.JSONObject to solve the problem

Note: Test the use of Ajax directly to the JSON data or there will be 415 errors, if the direct HTTP request post JSON data flow, test is normal, do not understand if the AJAX request to how to receive, know the friend trouble to help say, thank you.

Springmvc @RequestBody A workaround for receiving the JSON report HTTP 415 issue

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.