我在尝试PUT JSONOBbject时遇到异常 输入数据: { “KEY1”: “VALUE1” “KEY2”: “值2” }
代码段:
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)
决议中的任何指针?
答案 0 :(得分:0)
你需要在你的类路径中使用jersey-json JAR。