zoukankan      html  css  js  c++  java
  • 草稿代码,有时间整理

       @RequestMapping(value = "/hivesd", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
        public ResponseEntity getHiveSampleData(@RequestBody GetHiveRequest getHiveRequest) {
    
            // --------------------------Post Json-------------------------------
    
    
    
            String hiveTableName = tableMappingService.findHiveTableNameByUserTableName(getHiveRequest);
            RestTemplate restTemplate = new RestTemplate();
    
            //Http 请求URL
            String url = "http://localhost:8080/test";
            //Http Header
            HttpHeaders headers = new HttpHeaders();
            // 指定请求中的媒体类型信息
            MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
            headers.setContentType(type);
            //Accept代表发送端(客户端)希望接受的数据类型。
            headers.add("Accept", MediaType.APPLICATION_JSON.toString());
            String json = "{"k1":"v1"}";
            HttpEntity<String> entity = new HttpEntity<String>(json, headers);
            String restResult = restTemplate.postForObject(url, entity, String.class);
            System.out.println(restResult);
    
    
            //-------------------------Post Form------------------------
    
    
            url = "http://localhost:8080/testnotjson";
            headers = new HttpHeaders();
            headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
            MultiValueMap<String, String> map= new LinkedMultiValueMap<String, String>();
            map.add("key", "first.last@example.com");
            map.add("key", "first.last@example.com111");
            headers.add("Accept", MediaType.APPLICATION_JSON.toString());
            HttpEntity<MultiValueMap<String, String>> request = new HttpEntity(map, headers);
            restResult = restTemplate.postForObject(url, request, String.class);
            System.out.println(restResult);
    
            return null;
    
        }
    

      

  • 相关阅读:
    Climbing Stairs
    交换排序
    解析Ceph: Snapshot
    OpenStack Hacker养成指南
    从UnitedStack OS 1.0 Preview试用申请问卷调查学习OpenStack
    Tun/Tap interface tutorial
    Linux下的TUN/TAP编程
    基于KVM的虚拟化研究及应用
    Linux 上的基础网络设备详解
    linux下TUN/TAP虚拟网卡的使用
  • 原文地址:https://www.cnblogs.com/leodaxin/p/8335713.html
Copyright © 2011-2022 走看看