|
@@ -1,6 +1,7 @@
|
|
|
package com.wj.service.impl;
|
|
package com.wj.service.impl;
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
+import org.json.JSONArray;
|
|
|
|
|
|
|
|
import java.net.HttpURLConnection;
|
|
import java.net.HttpURLConnection;
|
|
|
import java.net.URL;
|
|
import java.net.URL;
|
|
@@ -17,7 +18,10 @@ public class SaveRecord {
|
|
|
JSONObject json = new JSONObject();
|
|
JSONObject json = new JSONObject();
|
|
|
json.put("ucid", ucid);
|
|
json.put("ucid", ucid);
|
|
|
json.put("url", url);
|
|
json.put("url", url);
|
|
|
-
|
|
|
|
|
|
|
+ // 创建一个空的JSONArray作为外层包裹
|
|
|
|
|
+ JSONArray dataArray = new JSONArray();
|
|
|
|
|
+ // 将你的JSON对象添加到空的JSONArray中
|
|
|
|
|
+ dataArray.put(json);
|
|
|
// 创建连接
|
|
// 创建连接
|
|
|
URL urlObj = new URL(sqlurl);
|
|
URL urlObj = new URL(sqlurl);
|
|
|
con = (HttpURLConnection) urlObj.openConnection();
|
|
con = (HttpURLConnection) urlObj.openConnection();
|
|
@@ -28,7 +32,7 @@ public class SaveRecord {
|
|
|
|
|
|
|
|
// 发送POST请求
|
|
// 发送POST请求
|
|
|
con.setDoOutput(true);
|
|
con.setDoOutput(true);
|
|
|
- byte[] out = json.toString().getBytes(StandardCharsets.UTF_8);
|
|
|
|
|
|
|
+ byte[] out = dataArray.toString().getBytes(StandardCharsets.UTF_8);
|
|
|
con.setFixedLengthStreamingMode(out.length);
|
|
con.setFixedLengthStreamingMode(out.length);
|
|
|
con.getOutputStream().write(out);
|
|
con.getOutputStream().write(out);
|
|
|
System.out.println(con.getResponseCode());
|
|
System.out.println(con.getResponseCode());
|