在我的Android项目中,我想发布bigsize json数据..所以,我使用了
String url1 = localhost://8080/myproject/sendData;
// initialize URL
URL url = new URL(url1);
String urlParameters = "myobject="
+ URLEncoder.encode(jsonobject, "UTF-8");
// instantiate a HttpURLConnection
HttpsURLConnection conn = (HttpsURLConnection) url.openConnection();
conn.setDoOutput(true);
// sending data as POST
conn.setRequestMethod("POST");
// set the length of the files
conn.setFixedLengthStreamingMode(urlParameters.getBytes().length);
// set headers
conn.setRequestProperty("Content-Type",
"application/x-www-form-urlencoded");
conn.setRequestProperty("My-Id", Id);
conn.setDoInput(true);
PrintWriter out = new PrintWriter(conn.getOutputStream());
out.print(urlParameters);
out.close();
在这段代码 urlParameters 我发送json数据..但问题是如果json数据很小那么它正在工作..但是大尺寸的json数据不起作用..为什么?