如下写法,会报错
Required type:HttpEntity<Map<String, String>>
Provided:HttpEntity<Map<String, String>[]>
接口提供方要求不能上传key,只能传递一个数组
public static String sendPOSTArrRequest(String url, Map<String, String> []params ) {
log.info("url:"+url);
log.info("params:"+params);
RestTemplate client = new RestTemplate();
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
HttpEntity<Map<String, String>> r = new HttpEntity<>(params, headers);
String data= client.postForObject(url, r, String.class);
return data;
}
从request对象中根据name去获取就行了