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());
} }
restTemplate.getForEntity restTemplate.getForObject GET请求的更多相关文章
- RestTemplate 超级严重BUG之 restTemplate.getForEntity对于下载文件的地址请求 header不起作用
错误下载:RestTemplate restTemplate=new RestTemplate();HttpHeaders httpHeaders=new HttpHeaders();httpHead ...
- 精讲RestTemplate第3篇-GET请求使用方法详解
本文是精讲RestTemplate第3篇,前篇的blog访问地址如下: 精讲RestTemplate第1篇-在Spring或非Spring环境下如何使用 精讲RestTemplate第2篇-多种底层H ...
- 精讲RestTemplate第4篇-POST请求方法使用详解
本文是精讲RestTemplate第4篇,前篇的blog访问地址如下: 精讲RestTemplate第1篇-在Spring或非Spring环境下如何使用 精讲RestTemplate第2篇-多种底层H ...
- RestTemplate发送HTTP、HTTPS请求
RestTemplate 使用总结 场景: 认证服务器需要有个 http client 把前端发来的请求转发到 backend service, 然后把 backend service 的结果再返 ...
- 精讲RestTemplate第7篇-自定义请求失败异常处理
本文是精讲RestTemplate第7篇,前篇的blog访问地址如下: 精讲RestTemplate第1篇-在Spring或非Spring环境下如何使用 精讲RestTemplate第2篇-多种底层H ...
- How to disable SSL certificate checking with Spring RestTemplate?(使用resttemplate访问https时禁用证书检查)
How to disable SSL certificate checking with Spring RestTemplate?(使用resttemplate访问https时禁用证书检查) **** ...
- Spring RestTemplate 之put、delete请求
●PUT请求:在RestTemplate中,PUT请求可以通过put方法调用,put方法的参数和前面介绍的postForEntity方法的参数基本一致,只是put方法没有返回值而已.举一个简单的例子, ...
- spring boot resttemplate发送post,get请求
参考博客: https://blog.csdn.net/weixin_42456466/article/details/80728387 https://www.cnblogs.com/QQParad ...
- SpringBoot集成RestTemplate
先把原文列出来: springboot实战之常用http客户端整合 springboot2.0集成RestTemplate -----------开始------------ SpringBoot应用 ...
- springcloud-alibaba手写负载均衡的坑,采用restTemplate,不能添加@loadbalanced注解,否则采用了robbin
采用springcloud-alibaba整合rabbion使用DiscoveryClient调用restful时遇到的一个问题,报错如下: D:\javaDevlepTool\java1.8\jdk ...
随机推荐
- OpenAI未至,Open-Sora再度升级!已支持生成16秒720p视频
Open-Sora 在开源社区悄悄更新了!现在支持长达 16 秒的视频生成,分辨率最高可达 720p,并且可以处理任何宽高比的文本到图像.文本到视频.图像到视频.视频到视频和无限长视频的生成需求.我们 ...
- Visual Studio 2019 自带混淆工具DotFuscator不需要去网络下载
http://t.zoukankan.com/daizhipeng-p-13492298.html 大家是否还在困扰发布的项目dll容易被人反编译呢,VS2019默认是没有安装DotFuscator的 ...
- Multisim 教程
Multisim 教程 Multisim主要是用来做电路图绘制.仿真的程序.本教程介绍Multisim的功能和使用方法. Multisim 界面简介 Multisim是电路设计套件里完成电路图绘制和仿 ...
- vue通过input选取apk文件上传,显示进度条
<template> <div class=""> <form action="" method="post" ...
- 03.Java 基础语法
1. 注释.标识符.关键字 三种注释 单行注释:// 多行注释:/* 多行注释 */ 文档注释: /** * @Description HelloWorld * @Author xxx */ 标识符 ...
- .NET有哪些好用的定时任务调度框架
前言 定时任务调度的相关业务在日常工作开发中是一个十分常见的需求,经常有小伙伴们在技术群提问:有什么好用的定时任务调度框架推荐的?今天大姚给大家分享5个.NET开源.简单.易用.免费的任务调度框架,帮 ...
- Ubuntu下MPICH的安装与配置
原创直达链接 一.MPICH的下载与安装 MPI安装文件下载地址: 博客下载地址 或 官网地址 可以下载3.4.2版本的,本文就是3.4.2版本 1.解压: sudo tar - zxvf mpich ...
- Cesium的HeadingPitchRange 用法
这个有别于headingpitchroll, headingpitchroll是用在orientation属性上的(比如相机的setView,flyTo,以及entities.add中) Headin ...
- C++ 初始化列表(Initialization List)
请注意以下继承体系中各class的constructors写法: 1 class CPoint 2 { 3 public: 4 CPoint(float x=0.0) 5 :_x(x){} 6 7 f ...
- 开源项目分享:ChatGPT 控制台聊天应用
开源项目分享:ChatGPT 控制台聊天应用 分享一个我最近完成的一个小应用,一个ChatGPT 的控制台聊天应用,大家都在搞AI,我也来玩一玩,顺便分享到社区,有兴趣的小伙伴可以去我的github主 ...