HttpClient_Post方式提交json字符串:
https://blog.csdn.net/qq_36023564/article/details/79615576
HttpClient 的 Post 提交表单简单示例
https://blog.csdn.net/w451373766/article/details/7162171?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-3.nonecase&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-3.nonecase
Httpresponse 取出获取的值并返回json
HttpResponse response = httpClient.execute(httpPost);
BufferedReader in = new BufferedReader(new InputStreamReader(response.getEntity()
.getContent()));
StringBuffer sb = new StringBuffer("");
String line = "";
String NL = System.getProperty("line.separator");
while ((line = in.readLine()) != null) {
sb.append(line + NL);
}
in.close();
String content = sb.toString();
System.out.println("end______________________________" + content);
content = content.replaceAll("\\r", "");
content = content.replaceAll("\\n", "");
content = content.replaceAll("\\t", "");
// content = StringEscapeUtils.unescapeJava(content);
// StringBuilder stringBuilder=new StringBuilder();
Map maps = (Map) JSON.parse(content);
JSONObject json = new JSONObject(maps);
return JsonResult.success(json);
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.5</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.9</version>
</dependency>