标签:header ase produce request mapping method set charset entity
请求:
RestTemplate restTemplate = new RestTemplate();
LinkedMultiValueMap body=new LinkedMultiValueMap();
body.add("map",dataService.runData());
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON_UTF8);
HttpEntity httpEntity = new HttpEntity(body,headers);
restTemplate.exchange("http://localhost:9001/getData",HttpMethod.POST,httpEntity,String.class);
接收:
@PostMapping(value = "getData",produces = {"application/json;charset = utf-8"})
public void getData(@RequestBody LinkedMultiValueMap map){
try {
dataService.runData(map.get("map"));
}catch (Exception e){
e.printStackTrace();
}
标签:header ase produce request mapping method set charset entity
原文地址:https://www.cnblogs.com/-llf/p/13839548.html