1. 传递FastJson
JSONObject result =restTemplate.postForObject(Url, JSONObject, JSONObject.class);
2. 传递DTO(用@RequestBody 接受)
JSONObject result =restTemplate.postForObject(Url,DTO, JSONObject.class);
3. mediaType = application/json
设置 HttpHeadersJSONObject result =restTemplate.postForObject(Url, formEntity, JSONObject.class);
4. form-data模式(用@RequestParam 接受)
MultiValueMap postParameters =new LinkedMultiValueMap<>();
postParameters.add(key, value);
JSONObject result =restTemplate.postForObject(Url, postParameters, JSONObject.class);
网友评论