서비스를 사용하기 위해 restTemplate을 사용하고 있습니다.RestTemplate이 APPLICATION_FORM_URLENCODED 및 Request Pojo와 함께 작동하지 않습니다.
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
HttpEntity request = new HttpEntity(countryRequest, headers);
CountryResponse response = restTemplate.postForObject(countryURL, request, CountryResponse.class);
countryRequest
그냥 문자열 필드 code
와 POJO의 객체입니다. restTemplate
은 jackson2HttpMessageConverter
이고 FormHttpMessageConverter
은 messageConverters
입니다.
나는 다음과 같은 예외가 점점 오전 :
org.springframework.web.client.RestClientException:
Could not write request: no suitable HttpMessageConverter found for request type [CountryRequest] and content type [application/x-www-form-urlencoded]
을하지만 대신 CountryRequest
의 MultiValueMap
를 사용하는 경우, 내가 200 응답 가지고 :
MultiValueMap<String, String> map= new LinkedMultiValueMap<>();
map.add(code, "usa");
HttpEntity<MultiValueMap<String, String>> request = new HttpEntity(map, headers);
여기 MultiValueMap
접근 방식을 대체 할 수있는 방법이 있나요을 ?