resttemplate 发送get请求
get请求的两种传参方式
参数拼接到url中
public void doGetTest() {String orgCode = "900000";String versionNo = "1573062384036";String body = null;try {ResponseEntity<String> forEntity = restTemplate.getForEntity("http://xxx.xxxxxx.xxx/xxx/xxxxxxxx?orgCode=" + orgCode + "&versionNo=" + versionNo, String.class);body = forEntity.getBody();System.out.println(body);} catch (Exception e) {ErrorLogger.log("调用接口异常,{}", e);}}
map传参
public String findMessage(String waybilNo){Map<String, String> params = new HashMap<>();params.put("waybillNo", waybilNo);String body = null;try {body = restTemplate.getForEntity(traceInHbaseUrl + "?waybillNo={waybillNo}", String.class, params).getBody();System.out.println(body);} catch (Exception e){ErrorLogger.log("调用接口异常,{}",e);}return body;}
getForEntity和getForObject区别(post同理)
上面使用的是getForEntity,接下来看一下getForEntity
public void doGetTest() {String orgCode = "900000";String versionNo = "1573062384036";String responBody = null;try {responBody = restTemplate.getForObject("http://192.168.124.82:17084/api/intercept/findInterceptWaybill?orgCode=" + orgCode + "&versionNo=" + versionNo, String.class);System.out.println(responBody);} catch (Exception e) {ErrorLogger.log("调用接口异常,{}", e);}}
- getForEntity返回的数据更加详细(status、header、body)
- getForObject指定一个返回类型,直接返回指定格式的body内容
以下是getForEntity返回结构的截图
resttemplate 发送get请求相关推荐
- RestTemplate 发送 Https 请求调用
RestTemplate 发送 Https 请求调用 个人博客:https://jacob.org.cn import org.apache.http.conn.ssl.NoopHostnameVer ...
- restTemplate发送put请求
restTemplate发送put请求 1.没有返回体 2.有返回体 HttpHeaders headers = new HttpHeaders(); headers.setContentType(o ...
- resttemplate发送post请求
/*** 向目的URL发送post请求* @param url 目的url* @param params 发送的参数* @return ResultVO*/public static ResultVO ...
- springboot 使用restTemplate 发送https请求 忽略ssl证书
最近在写接口的时候给对方回推数据,发送https请求的时候遇到这么个报错:javax.net.ssl.SSLHandshakeException: sun.security.validator.Val ...
- restTemplate 发送post请求
<!--jackson 依赖--><dependency><groupId>com.fasterxml.jackson.core</groupId>&l ...
- Spring中使用RestTemplate发送Http请求
作为一个Java开发选手,平时调用外部服务都是通过PRC接口,而这次业务下游只提供Http接口,就有点捉急... RestTemplate的基本使用 RestTemplate是spring实现的,基于 ...
- RestTemplate 发送 get 请求使用误区 多值为null
http://blog.csdn.net/zhousenshan/article/details/71055687 ****************************************** ...
- RestTemplate发送form-data请求上传rul资源文件及对象参数
需求 上传文件服务中的文件到其他平台 接口描述:用于上传工程日志相关资料 请求url:/cq-szh-projectdocumentscomputesvc/api/service/addEnginee ...
- 使用Fiddler监控使用RestTemplate发送网络请求的Java应用
原始Java代码: public static void getUserInfo() {String responseStr = null;RestTemplate template = new Re ...
- 【RestTemplate发送post、get请求】
RestTemplate发送post.get请求 使用RestTemplate发送post请求 private String restTemplateByPost(String apiUrl, Map ...
最新文章
- git diff 比较文件_使用Python创建你自己的diff工具
- JAVA中对日期格式的处理
- ROI(投资回报率 Return On Investment)
- 前端vue显示柱状图_Vue接入Echarts 显示柱状图饼图
- 没有人会告诉您乘坐飞机时的几个事实 但是您一定要知道
- 工作309:selectaccount方法接收值
- sql空字符串判断函数_access常用的内置函数
- python编程语言-Python有望超越Java排第二?风变编程解析编程语言新趋势
- 性能为王:选择模拟监控的10大理由!
- 【路径规划】基于matlab改进的遗传算法栅格地图路径规划【含Matlab源码 525期】
- 安装前端插件 FeHelper
- OSPF LSA内容解析及SPF算法分析
- html动画 箭头线条,纯CSS3实现的箭头图标和箭头循环动画
- sparc处理器开发工具_SPARC处理器启动代码的分析与编程
- qs的arrayFormat与SpringBoot接收数组问题
- 英雄杀小程序微信区分服务器吗,英雄杀小程序
- Comment 的使用
- 《文明之光 第二册》一一16.2 寻找冯·布劳恩(2)
- 算法:汉诺塔问题(世界末日问题)
- 天龙八部音乐文件提取
热门文章
- 县级公立医院改革明年推开 今年再增700试点
- 【写paper系列之一】怎样写好introduction--转自nature
- 读了下神书 Introduction to Linear Optimization
- 【技术贴】自己制作支持QQ空间背景音乐的链接教程||QQ免费空间音乐外链自己上传制作教程...
- 天牛须和贪心算法_天牛须算法
- android硬盘格式化时间,安卓手机格式化恢复
- 音频处理工具SOX详解
- 第一章 : JVM与体系结构
- 允许用户使用 MAK 密钥激活 Office 2010 批量许可版
- linux鼠标切换窗口的快捷键设置,Xshell中如何设置鼠标快捷键