本人微信 zf363133213 欢迎各位添加好友,共同探讨问题
第一种方法:
public Object test(){
HttpHeaders headers = new HttpHeaders();//http请求头
RestTemplate restTemplate = new RestTemplate();
headers.setContentType(MediaType.parseMediaType("application/json;charset=UTF-8"));
headers.add("versionNo","123");
Map<String,Object> body = new HashMap<>();//请求body
body.put("carNo","123");
HttpEntity<Map<String,Object>> requestEntity=new HttpEntity<Map<String,Object>>(body,headers);
Map<String,Object> map = restTemplate.postForObject("http://test/get",requestEntity,Map.class);
//String jsonStr =restTemplate.postForObject("http://test/get",requestEntity,String.class);
retrurn map;
}
第二种方法:
public Object test(){
Map<String,Object> co