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

restTemplate.getForEntity restTemplate.getForObject GET请求的更多相关文章

  1. RestTemplate 超级严重BUG之 restTemplate.getForEntity对于下载文件的地址请求 header不起作用

    错误下载:RestTemplate restTemplate=new RestTemplate();HttpHeaders httpHeaders=new HttpHeaders();httpHead ...

  2. 精讲RestTemplate第3篇-GET请求使用方法详解

    本文是精讲RestTemplate第3篇,前篇的blog访问地址如下: 精讲RestTemplate第1篇-在Spring或非Spring环境下如何使用 精讲RestTemplate第2篇-多种底层H ...

  3. 精讲RestTemplate第4篇-POST请求方法使用详解

    本文是精讲RestTemplate第4篇,前篇的blog访问地址如下: 精讲RestTemplate第1篇-在Spring或非Spring环境下如何使用 精讲RestTemplate第2篇-多种底层H ...

  4. RestTemplate发送HTTP、HTTPS请求

    RestTemplate 使用总结   场景: 认证服务器需要有个 http client 把前端发来的请求转发到 backend service, 然后把 backend service 的结果再返 ...

  5. 精讲RestTemplate第7篇-自定义请求失败异常处理

    本文是精讲RestTemplate第7篇,前篇的blog访问地址如下: 精讲RestTemplate第1篇-在Spring或非Spring环境下如何使用 精讲RestTemplate第2篇-多种底层H ...

  6. How to disable SSL certificate checking with Spring RestTemplate?(使用resttemplate访问https时禁用证书检查)

    How to disable SSL certificate checking with Spring RestTemplate?(使用resttemplate访问https时禁用证书检查) **** ...

  7. Spring RestTemplate 之put、delete请求

    ●PUT请求:在RestTemplate中,PUT请求可以通过put方法调用,put方法的参数和前面介绍的postForEntity方法的参数基本一致,只是put方法没有返回值而已.举一个简单的例子, ...

  8. spring boot resttemplate发送post,get请求

    参考博客: https://blog.csdn.net/weixin_42456466/article/details/80728387 https://www.cnblogs.com/QQParad ...

  9. SpringBoot集成RestTemplate

    先把原文列出来: springboot实战之常用http客户端整合 springboot2.0集成RestTemplate -----------开始------------ SpringBoot应用 ...

  10. springcloud-alibaba手写负载均衡的坑,采用restTemplate,不能添加@loadbalanced注解,否则采用了robbin

    采用springcloud-alibaba整合rabbion使用DiscoveryClient调用restful时遇到的一个问题,报错如下: D:\javaDevlepTool\java1.8\jdk ...

随机推荐

  1. [FE] 实时视频流库 hls.js 重载切换资源的方式

    hls 播放需要先 attachMedia,然后 loadSource. 如果切换 resource,需要先执行 hls.destroy(),否则会出现混乱. destroy 之后再依次进行 hls ...

  2. [Contract] Truffle 使用流程

    Installation $ npm install -g truffle Choose ethereum client (Ganache OR truffle build in `truffle d ...

  3. Stable Diffusion中的embedding

    Stable Diffusion中的embedding 嵌入,也称为文本反转,是在 Stable Diffusion 中控制图像样式的另一种方法.在这篇文章中,我们将学习什么是嵌入,在哪里可以找到它们 ...

  4. C语言结构体的内存分配

    一.结构体内存分配原则 原则一:结构体中元素按照定义顺序存放到内存中,但并不是紧密排列.从结构体存储的首地址开始 ,每一个元素存入内存中时,它都会认为内存是以自己的宽度来划分空间的,因此元素存放的位置 ...

  5. 在Linux下想要删除一个目录需要怎样的权限

    场景一 在Home目录下创建一个目录dirtest,然后使用chmod 333 dirtest修改目录权限.这时候dirtest的权限为d-wx-wx-wx,如果执行rm -r dirtest可以进行 ...

  6. 小程序中 canvas 的图片不支持 base64 格式

    首先使用 wx.base64ToArrayBuffer 将 base64 数据转换为 ArrayBuffer 数据,使用FileSystemManager.writeFile 将 ArrayBuffe ...

  7. 网络拓扑—WEB-IIS服务搭建

    目录 WEB-IIS服务搭建 网络拓扑 配置网络 IIS PC 安装IIS服务 配置IIS服务(默认站点) PC机访问网页 配置IIS服务(新建站点) PC机访问网页 WEB-IIS服务搭建 网络拓扑 ...

  8. Selenium4自动化测试8--控件获取数据--上传、下载、https和切换分页

    10-上传 上传不能模拟用户在页面上选择本地文件,只能先把要上传的文件先准备好在代码里上传 import time from selenium.webdriver.support.select imp ...

  9. 现代农业|AIRIOT智慧农业管理解决方案

    ​ 智慧农业是现代化技术在农业领域的应用和成果,其中物联网技术在促生产.保产量和降本增效方面起到了至关重要的作用.运用传感技术和软件平台系统对农业生产进行智能化平台化管理,解决掉传统农业问题的诸多痛点 ...

  10. 物联网平台在AIoT领域8大场景应用

    物联网平台技术在AIoT智慧物联领域的应用越来越深入,尤其是在智慧城市建设项目中,提供了强有力的技术底座工具支撑.ToG的项目需要"门当户对"的服务商具备完善的资质和靠谱的技术服务 ...