0

我在尝试 PUT JSONOBbject 时遇到以下异常,例如 inputData: { "key1":"value1", "key2":"value2" }

代码片段:

          WebResource webResource = client
               .resource(url);
     response = webResource.type(MediaType.APPLICATION_JSON_TYPE)
               .put(ClientResponse.class,inputData);

例外:

        com.sun.jersey.api.client.ClientHandlerException: com.sun.jersey.api.client.ClientHandlerException: A message body writer for Java type, class org.json.JSONObject, and MIME media type, application/json, was not found
at com.sun.jersey.client.urlconnection.URLConnectionClientHandler.handle(URLConnectionClientHandler.java:149)
at com.sun.jersey.api.client.Client.handle(Client.java:648)
at com.sun.jersey.api.client.WebResource.handle(WebResource.java:670)
at com.sun.jersey.api.client.WebResource.access$200(WebResource.java:74)
at com.sun.jersey.api.client.WebResource$Builder.put(WebResource.java:533)
at httptransaction.CommonHttpClient.doPutConnect(CommonHttpClient.java:222)

任何解决方案的指针?

4

1 回答 1

0

您的类路径中需要 jersey-json JAR。

于 2013-01-16T14:38:38.373 回答