RestTemplate restTemplate = new RestTemplate(); HttpHeaders headers = new HttpHeaders(); MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8"); headers.setContentType(type); headers.add("Accept", MediaType.APPLICATION_JSON.toString()); String jsonStr = JSONObject.toJSONString(params); HttpEntity formEntity = new HttpEntity( jsonStr ,headers); String result = restTemplate.getForObject(url, String.class);
闲话不多说,直接看代码
原文地址:https://www.cnblogs.com/zjting/p/10980966.html
时间: 2024-10-31 10:11:21