//创建请求头
        HttpHeaders headers = new HttpHeaders();
        if (cookies != null) {
            List<String> cookieList = Arrays.stream(cookies)
                .map(obj -> obj.getName() + "=" + obj.getValue())
                .collect(Collectors.toList());
            headers.put(HttpHeaders.COOKIE, cookieList);
        }

        MultiValueMap<String, Object> paramMap = new LinkedMultiValueMap<String, Object>();
        paramMap.add("appType", appType);
        paramMap.add("userId", userId);
        org.springframework.http.HttpEntity<MultiValueMap<String, Object>> httpEntity
            = new org.springframework.http.HttpEntity<>(paramMap, headers);

        ResponseEntity<String> stringResponseEntity = restTemplate.postForEntity(YiDaConstants.URL, httpEntity, String.class);

更多推荐