【发布时间】:2018-11-28 11:34:24
【问题描述】:
创建 POST 的空白。
public void doPostRequest(Object input, String methodName) throws IOException {
try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
String JSON_STRING = writer.writeValueAsString(input);
StringEntity requestEntity = new StringEntity(
JSON_STRING,
ContentType.APPLICATION_JSON);
HttpPost postMethod = new HttpPost(methodName);
postMethod.setEntity(requestEntity);
HttpResponse rawResponse = httpClient.execute(postMethod);
}
}
methodName - 它的字符串如:
http://myservice:8180/location-service/add
但是我的postMethod初始化后会变成:
http://myservice:8180/location-service/sync_api/add HTTP/1.1
什么是 HTTP/1.1 ?以及如何删除它??
【问题讨论】:
-
我需要使用 JSON_STRING
标签: java spring post apache-httpclient-4.x fluent