zoukankan      html  css  js  c++  java
  • RestTemplate发送json请求

      JSONObject json = new JSONObject();
                        json.put("train_date", train_date);
                        json.put("from_station", fromStationCode);
                        json.put("to_station", toStationCode);
                        json.put("logFlag", logFlag);
    
                        HttpHeaders headers = new HttpHeaders();
                        MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
                        headers.setContentType(type);
                        headers.add("Accept", MediaType.APPLICATION_JSON.toString());
                        HttpEntity<String> formEntity = new HttpEntity<String>(json.toString(), headers);
                        String s= restTemplate.postForEntity(url,formEntity,String.class).getBody();
  • 相关阅读:
    HttpClient
    充值保存
    button 样式
    创建窗口
    第十一次作业
    第十次作业
    第九次作业
    第八次作业
    第七次作业
    第六次作业
  • 原文地址:https://www.cnblogs.com/yongguang1990/p/10223857.html
Copyright © 2011-2022 走看看