简体   繁体   English

RestTemplate无法编写请求:找不到适合请求类型[java.util.HashMap]的HttpMessageConverter

[英]RestTemplate Could not write request: no suitable HttpMessageConverter found for request type [java.util.HashMap]

I use Maven + Spring 4.1.0 + Java 6 and I want use RestTemplate().postForEntity(url, request, responseType) 我使用Maven + Spring 4.1.0 + Java 6,我想使用RestTemplate()。postForEntity(url,request,responseType)

while I execute this code : 当我执行这段代码时:

HttpEntity<MultiValueMap<String, Object>> entity = new HttpEntity<MultiValueMap<String, Object>>(parameters, headers);
final RestTemplate restTemplate = RestTemplateUtils.createHttpTemplate();
ResponseEntity<String> response = restTemplate.postForEntity(url, entity,
            String.class);

but I have this error: 但我有这个错误:

org.springframework.http.converter.HttpMessageNotWritableException: Could not write request: no suitable HttpMessageConverter found for request type [java.util.HashMap] at org.springframework.http.converter.FormHttpMessageConverter.writePart(FormHttpMessageConverter.java:310) at org.springframework.http.converter.FormHttpMessageConverter.writeParts(FormHttpMessageConverter.java:270) at org.springframework.http.converter.FormHttpMessageConverter.writeMultipart(FormHttpMessageConverter.java:260) at org.springframework.http.converter.FormHttpMessageConverter.write(FormHttpMessageConverter.java:200) at org.springframework.http.converter.FormHttpMessageConverter.write(FormHttpMessageConverter.java:1) at org.springframework.web.client.RestTemplate$HttpEntityRequestCallback.doWithRequest(RestTemplate.java:596) at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:444) at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:409) at org.springframework.web. org.springframework.http.converter.HttpMessageNotWritableException:无法写入请求:在org.springframework.http.converter.FormHttpMessageConverter.writePart(FormHttpMessageConverter.java:310)处找不到请求类型为[java.util.HashMap]的合适的HttpMessageConverter。 org.springframework.http.converter.FormHttpMessageConverter.writeMultipart(FormHttpMessageConverter.java:260)的org.springframework.http.converter.FormHttpMessageConverter.writeParts(FormHttpMessageConverter.java:270)org.springframework.http.converter.FormHttpMessageConverter.write(FormHttpMessageConverter.FormHttpMessageConverter.write org.springframework.http.converter.FormHttpMessageConverter.write(FormHttpMessageConverter.java:1)上的org.springframework.web.client.RestTemplate $ HttpEntityRequestCallback.doWithRequest(RestTemplate.java:596)上的.java:200)。 org.springframework.web.client.RestTemplate.execute(RestTemplate.java:409)上的org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:444)。 client.RestTemplate.postForEntity(RestTemplate.java:310) client.RestTemplate.postForEntity(RestTemplate.java:310)

该问题是由于旧的Spring版本导致的,因此需要迁移到Spring版本4,此问题已解决。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 RestClientException:无法写入请求:找不到适合请求类型的HttpMessageConverter - RestClientException: Could not write request: no suitable HttpMessageConverter found for request type 无法写入请求:找不到适合请求类型和内容类型的HttpMessageConverter [application / x-java-serialized-object] - Could not write request: no suitable HttpMessageConverter found for request type and content type [application/x-java-serialized-object] HttpMessageConverter 异常:RestClientException:无法写入请求:找不到合适的 HttpMessageConverter - HttpMessageConverter exception : RestClientException: Could not write request: no suitable HttpMessageConverter found org.springframework.web.client.RestClientException:无法写入请求:找不到适合请求类型的 HttpMessageConverter - org.springframework.web.client.RestClientException: Could not write request: no suitable HttpMessageConverter found for request type 找不到适合请求类型 [java.util.LinkedHashMap] 和内容类型 [multipart/form-data] 的 HttpMessageConverter - no suitable HttpMessageConverter found for request type [java.util.LinkedHashMap] and content type [multipart/form-data] Java Android Spring:找不到适合请求类型的HttpMessageConverter - java android spring: no suitable HttpMessageConverter found for request type 没有为响应类型找到合适的HttpMessageConverter - Custom RestTemplate - No suitable HttpMessageConverter found for response type - Custom RestTemplate 未找到类型为java.util.HashMap的返回值的转换器 - No converter found for return value of type: class java.util.HashMap java 中的 HTTP POST 引发错误 - 找不到合适的 HttpMessageConverter 将请求正文读取到 object02ABBBA2F2A298EBDCC4 类型 - HTTP POST in java throws an error - no suitable HttpMessageConverter found to read request body into object of type class 找不到媒体类型 = 应用程序/xml,类型 = 类 java.util.HashMap$Values 的 MessageBodyWriter - MessageBodyWriter not found for media type=application/xml, type=class java.util.HashMap$Values
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM