访问外部接口

RestTemplate restTemplate = new RestTemplate();
String roomurl = "https://qyapi.weixin.qq.com/cgi-bin/gettoken";
Map<String, Object> map = new HashMap<>();
map.put("corpid", "xxxxxxxx");
map.put("corpsecret", "xxxxxxxxxxxxxxxxxx");
org.springframework.http.HttpEntity<Map> roomentity = new org.springframework.http.HttpEntity<>(map);
JSONObject jsonObject1 = restTemplate.postForObject(roomurl, roomentity, JSONObject.class);
System.out.println(jsonObject1.toString());
上一篇:SpringCloud——Rest利用RestTemplate调用


下一篇:RestTemplate用法