调用第三方接口 接到反参 存数据
public static void main2(String[] args) { //通过http的协议去掉接口 RestTemplate restTemplate = new RestTemplate(); String req= "{\n" + "\t\"name\": \"猪猪侠\",\n" + "\t\"address\": \"中国\"\n" + "}"; //通过http的协议去掉第三方接口 String response = restTemplate.postForObject("http://xxxxx", req, String.class); System.out.println("返回参数"+response); //把返回的json进行转换 并存在对象中 TcHits tcHits = new Gson().fromJson(response, TcHits.class); System.out.println(tcHits); }