记得try,catch....................妈的他们的什么
MultiValueMap try { //复杂构造函数的使⽤ SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory(); requestFactory.setConnectTimeout(10000);// 设置超时 requestFactory.setReadTimeout(10000); //利⽤复杂构造器可以实现超时设置,内部实际实现为 HttpClient RestTemplate restTemplate = new RestTemplate(requestFactory); HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.APPLICATION_JSON_UTF8); String[] ids={\"8a6980fa762870db01762886a3f50000\ //设置访问参数 HashMap String url = \"http://ip:port/tDeviceInfo/getbyids\"; //设置访问的Entity HttpEntity requestEntity = new HttpEntity<>(params, headers);//params 请求体内容, headers请求头内容 JSONObject jsonObject = iRestTemplate.postForObject(url, requestEntity, JSONObject.class); System.out.println(jsonObject); }catch (Exception e){ e.printStackTrace(); } View Code 因篇幅问题不能全部显示,请点此查看更多更全内容