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