使用RestTemplate方法建一个http请求,post连接
从一个模块调用另一个模块数据,http请求post连接
public static List<Map<String, Object>> tallyCheck(String str) {//参数一般是经过json转换的字符串
//存储处理过的数据
List<Map<String, Object>> list = null;
try {
Map<String, String> params = new HashMap<>();
//这里的给参数起了一个名字叫“data”放到了连接里
params.put(“data”, str);
RestTemplate restTemplate = new RestTemplate();
HttpHeaders headers = new HttpHeaders();
//设置请求头
headers.setContentType(MediaType.APPLICATION_JSON_UTF8);
//调用接口的路径
ResponseEntity result = restTemplate.exchange(comboxUtil.systemConf.getEngineUrl() + “/tallyRuleAutoMatchService/autoMatchCustomData”,
HttpMethod.POST, new HttpEntity(JSON.toJSONString(params), headers), String.class);
//拿到返回值
String resp = result.getBody();
if (StringUtils.isNotEmpty(resp)){
//解析json串
list = JSON.parseObject(resp, new TypeReference<List<Map<String, Object>>>() {});
}
} catch (Exception e) {
logger.error(“tallyCheck error:”,e);
}
return list;
}
- 点赞
- 收藏
- 分享
- 文章举报
- 使用ASP.NET Web Api构建基于REST风格的服务实战系列教程【五】——在Web Api中实现Http方法(Put,Post,Delete)
- 火狐浏览器使用RESTClient发送post请求方法
- Android系列之网络(三)----使用HttpClient发送HTTP请求(分别通过GET和POST方法发送数据)
- 使用RestTemplate post方式提交表单数据
- 使用HTTP请求协议之Post与Get方法的区别
- 使用RestTemplate发送post和delete请求
- 使用 RestTemplate 访问 Restful API 的方法
- c#连接access2003操作必须使用一个可更新的查询解决方法
- (三)----使用HttpClient发送HTTP请求(分别通过GET和POST方法发送数据)
- 从零开始学_JavaScript_系列(22)——dojo(9)(表单、JsonRest的post方法,widget的使用思路)
- 抓包工具Fiddler的使用教程(十一):如何知道HTTP请求是POST方法还是GET方法
- rails 关于连接多个数据库使用同一个database.yml文件的方法
- HttpHeader,restTemplate.postForObject()使用
- 利用 restTemplate发送application/json的请求,By一个后端发送http请求的神器
- 一个支持tcp多客户端连接的例子,轻松认识linux select函数的基本原理和使用方法
- WCF Rest:不使用UriTemplate使用post方式传参解决HTTP400问题以及参数映射问题
- Android系列之网络(三)----使用HttpClient发送HTTP请求(分别通过GET和POST方法发送数据)
- 火狐浏览器使用RESTClient发送post请求方法
- Android系列之网络(三)----使用HttpClient发送HTTP请求(分别通过GET和POST方法发送数据)
- Simple REST Client POST使用方法