A recent project on the line encountered a scratching the bug, the development environment and test environment are normal, once to the production environment on the report "Network timeout", after careful analysis, the final positioning to the relevant code section, so the local debugging.
The process is roughly like this, the page sends an AJAX request, the background receives this AJAX request to request a specified URL, the problem is on the request this URL. Local debugging is the case, if you replace the cost of the URL, then normal, if replaced by the remote specified URL, then tomcat will report an error: Exception in thread "main" Java.io.IOException:Server Returned HTTP response code:400 for URL xxx.
The Final solution is as follows, and the following are the relevant code snippets:
String params = Request.getparameter ("params");
Jsonobject msgobj = Json.parseobject (params);
result = Getresponsefromurl (MGW, New String (Msgobj.tostring (). GetBytes ("Iso8859-1"), "UTF-8"). ReplaceAll ("\", "'"). GetBytes ());
The main place is a single transcoding and one substitution, one transcoding is the conversion from iso8859-1 to UTF-8, and one substitution means replacing all the double quotes in the JSON string with single quotes.