zoukankan      html  css  js  c++  java
  • restTemplate.getForEntity restTemplate.getForObject GET请求

    //带参数
    @Test
        public void testGet1(){
            
            String url = "http://IP:PORT/query?token={token}&memNo={memNo}";
            RestTemplate restTemplate = new RestTemplate();
    
            Map<String,Object> paramMap=new HashMap<>();
            paramMap.put("token","111");
            paramMap.put("memNo", "222");
            
        
            ResponseEntity<String> zhimaAuthResponse = restTemplate.getForEntity(url, String.class, paramMap);
    //        String zhimaAuthResponse = restTemplate.getForObject(url, String.class, paramMap);
            System.out.println(zhimaAuthResponse.getStatusCode());
            if (HttpStatus.OK == zhimaAuthResponse.getStatusCode()) {
                System.out.println(zhimaAuthResponse.getBody());
                System.out.println(zhimaAuthResponse.getHeaders());
            }
            
        }
        
        
        //不带参数
        @Test
        public void testGet2(){
            String url = "http://IP:PORT/refreshcache";
            
            RestTemplate restTemplate = new RestTemplate();
            
            ResponseEntity<String> zhimaAuthResponse = restTemplate.getForEntity(url, String.class);
            System.out.println(zhimaAuthResponse.getStatusCode());
            if (HttpStatus.OK == zhimaAuthResponse.getStatusCode()) {
                System.out.println(zhimaAuthResponse.getBody());
                System.out.println(zhimaAuthResponse.getHeaders());
            }
            
        }
        
        
  • 相关阅读:
    web工程导入新环境的注意事项
    Mysql group by,order by,dinstict优化
    Dijkstra and Floyd算法
    百度面试题
    腾讯面试题
    百度笔试3
    百度笔试2
    百度笔试1
    百度2011实习生招聘笔试题
    百度2011.10.16校园招聘会笔试题
  • 原文地址:https://www.cnblogs.com/oktokeep/p/13326987.html
Copyright © 2011-2022 走看看