DefaultAsyncHttpClient asyncHttpClient = new DefaultAsyncHttpClient();
Map<String, String> params = new HashMap<>();
params.put("deviceId","11111111111111");
params.put("devName",eventInfo.getIotName());
Request r = new RequestBuilder()
.setUrl("http://***.***.***.**:****/gateway")
.setBody(JSONObject.toJSONString(params))
.addHeader("Content-Type", "application/json")
.build();
ListenableFuture<Response> future = asyncHttpClient.executeRequest(r);
try {
Response response = future.get();
} catch (Exception e) {
e.printStackTrace();
} finally {
asyncHttpClient.close();
}
java http get请求传json对象
于 2023-07-01 09:02:57 首次发布