我试图在不知道结果对象类型的情况下使用休息端点。基本上我这样做了。
try {
ClientConfig clientConfig = new DefaultClientConfig();
Client client = Client.create(clientConfig);
WebResource webResource = client.resource(url);
ClientResponse response = null;
if (headerMap.size() > 0) {
for (String head : headerMap.keySet())
response = webResource.accept(contentType)
.header(head, headerMap.get(head))
.type(contentType)
.post(ClientResponse.class, paramMap);
} else {
response = webResource.type(contentType).post(
ClientResponse.class, paramMap);
}
....
但每次我打电话时都会收到错误
Caused by: com.sun.jersey.api.client.ClientHandlerException: A message body writer for Java type, class java.util.HashMap, and MIME media type, application/json, was not found
检查其他帖子似乎有一个错误的参数,我发现很多类似的但不知道如何解决这个,任何想法?
我添加了这个希望可以帮助,如在其他帖子中看到但没有运气......
@WebServlet(
urlPatterns = "/",
initParams = @WebInitParam(name = ">com.sun.jersey.api.json.POJOMappingFeature", value = "true")
)
感谢。