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);
闲话不多说,直接看代码