我对此进行了大量研究,但一直无法找到解决方案。我已经创建了最简单的单元测试来获取单个实体,但仍然收到“无法找到转换器”异常。我已将 org.reSTLet.ext.servlet.jar、org.json.jar 和 org.reSTLet.ext.net.jar 包含在我的类路径中。我还可以看到返回的 json,并且能够使用 cr.get(MediaType.APPLICATION_JSON) 方法进行打印。
ClientResource cr = new ClientResource("http://localhost:8888/r/establishment/29");
Establishment est = cr.get(Establishment.class);
System.out.println("Establishment name is " + est.getName());
我在 GAE 上使用reSTLet-gae-2.1rc6 vs 1.7.1
最佳答案
您需要注册一个转换器。示例:
Engine.getInstance().getRegisteredConverters().add(new JacksonConverter());
查看具有相同解决方案但问题不同的问题:Android to gae restlet example doesn't work on the Android side
我在这里找到了解决方案:https://stackoverflow.com/a/5205993/435605
关于java - ReSTLet : Unable to find a converter for this representation : [application/json, UTF-8],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12433277/