设置请求头

HttpHeaders headers = new HttpHeaders();

headers.add("Content-Type", "application/x-www-form-urlencoded");

HttpEntity<MultiValueMap<String, Object>> r = new HttpEntity<>(postParameters, headers);

入参放到实体

MultiValueMap<String, String> requestEntity = new LinkedMultiValueMap<>();

requestEntity.add("clientFlag", clientFlag);

requestEntity.add("xml", xml);

requestEntity.add("verifyData", strMd5); 

HttpEntity<MultiValueMap<String, Object>> r = new HttpEntity<>(postParameters, headers);

public class HttpEntity<T> {

private final HttpHeaders headers;

private final T body;

public HttpEntity(T body, MultiValueMap<String, String> headers) {

this.body = body;

HttpHeaders tempHeaders = new HttpHeaders();

if (headers != null) {

tempHeaders.putAll(headers);

}

this.headers = HttpHeaders.readOnlyHttpHeaders(tempHeaders);

}

}

 

接下来就是发送POST请求 和接收参数了,用啥都行了

 

Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐