#发送参数:#参数 httpEntity组装EpbParam param = new EpbParam(); param.setData(CouponOrder);
HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.APPLICATION_JSON); HttpEntity<EpbParam<CouponOrder>> entity = new HttpEntity<EpbParam<CouponOrder>>(param, headers);
#返回值 ParameterizedTypeReference
ParameterizedTypeReference parameterizedTypeReference = new ParameterizedTypeReference<EpbResponse<ThirdPartyResponse,CouponOrder>>() {}; ResponseEntity<EpbResponse<ThirdPartyResponse,CouponOrder>> result = restTemplate.exchange(url, HttpMethod.POST, entity, parameterizedTypeReference);result.getBody();
RestTemplate 遇到泛型参数时,用exchange方法
最新推荐文章于 2024-03-07 09:17:44 发布