首页 > 其他 > 详细

restTemplate.postForObject接口请求

时间:2021-06-17 20:19:40      阅读:21      评论:0      收藏:0      [点我收藏+]

一、post请求【接口请求参数有params】

       RestTemplate restTemplate = new RestTemplate();
        String url =domesticAPP_url_Online+"readBook/listReadBookByCode";

    
        JSONObject paramsJ = JSON.parseObject(params);
        Map map = new HashMap();
        map.put("token",LoginToken);

        MultiValueMap<String, Object> postParameters =  new LinkedMultiValueMap();
        postParameters.add("params", JSON.toJSONString(map));    //http接口请求类型为json格式

        /*调用接口*/
        HttpEntity<MultiValueMap<String, Object>> request = new HttpEntity<>(postParameters,headers);
        JSONObject response = restTemplate.postForObject(url, request, JSONObject.class);

  

 

restTemplate.postForObject接口请求

原文:https://www.cnblogs.com/jiangger/p/14894656.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!