3
我使用DropWizard與球衣作出從服務器接受JSON和將其映射到POJO的客戶端。但是,調用客戶端時出現此錯誤。錯誤解析媒體類型「應用/ JSON;編碼= UTF8,字符集= UTF8」
java.lang.IllegalArgumentException: Error parsing media type 'application/json;encoding=utf8, charset=utf-8'
我的代碼如下:
@Path("/something")
@Produces(MediaType.APPLICATION_JSON)
public class SampleClient {
final Client client;
WebResource.Builder builder;
public SampleClient (Client client) {
this.client = client;
this.builder = client.resource("http://localhost/mysample/service").type("application/json");
}
@GET
public MyMapper getSomething() {
MyMapper result = builder.accept("application/json").get(MyMapper.class);
return result;
}
}
我在做什麼錯?
同時更改'.TYPE(...)'和'。接受(...)''到應用程序/ JSON的; charset = utf8'也沒有幫助。順便說一句我的客戶在消費這個服務:通過'http://opentable.herokuapp.com/api/restaurants名= taj' – Anthony
我知道了。這是服務器返回Content-type中的兩個參數。它適用於Firefox REST客戶端。我會在另一個客戶端查看它。 – helderdarocha
是的,我在Chrome上使用POSTMAN,它向我顯示數據也很好。但是,我的DropWizard/Jersey客戶端由於某種原因無法解析它。 – Anthony