如下:
SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory();
factory.setConnectTimeout(3000);
factory.setReadTimeout(3000);
RestTemplate restTemplate = new RestTemplate();
restTemplate.setRequestFactory(factory);
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
HttpEntity<String> httpEntity = new HttpEntity<>(MessageFormat.format("aa={0}&bb={1}&cc={2}","xxx", "xxx", "xxx"),headers);
ResponseEntity<String> response = restTemplate.postForEntity(url, httpEntity, String.class);