restTemplate带Headers远程调用接口

String url = "http://www.test.com/Order/update";
Map<String,Object> chatMap = new HashMap<>();
chatMap.put("orderId",order.get("id"));
chatMap.put("num",chatGoodsMap.get("num"));
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
HttpEntity<Map<String, Object>> httpEntity = new HttpEntity<>(chatMap, headers);
ResponseEntity<String> response = restTemplate.postForEntity(url, httpEntity, String.class);
System.out.println("response=========="+response);

猜你喜欢

转载自blog.csdn.net/qq_38410795/article/details/133345042
今日推荐