restTemplate.postForObject接口请求


一、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);

  

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM