设置请求头

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

技术共进,成长同行——讯飞AI开发者社区

更多推荐