//带参数
@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());
        }
        
    }
    
    

 

相关文章:

  • 2022-01-03
  • 2021-06-01
  • 2021-08-02
  • 2021-08-08
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-01-07
  • 2021-05-15
  • 2022-12-23
  • 2021-05-20
  • 2021-08-30
  • 2022-12-23
相关资源
相似解决方案