Android 上的 Restlet - 序列化问题

发布于 2024-10-02 19:35:22 字数 367 浏览 0 评论 0原文

我正在尝试使用 Restlet 2.1 检索序列化类,其中 Android 作为客户端,GAE 作为服务器。这是相关的代码:

ClientResource cr = new ClientResource("http://localhost:8888/mydata");
// Get the MyData object
MyDataResource resource = cr.wrap(MyDataResource.class);
MyData myData = resource.retrieve();

我最初在独立的 JSE 类中测试了它,一切正常。 当我尝试在 Android 中运行相同的东西时,myData 对象为 null。有什么想法吗?

I am trying to retrieve serialized classes using Restlet 2.1 with Android as the client and GAE as the server. This is the relevant code:

ClientResource cr = new ClientResource("http://localhost:8888/mydata");
// Get the MyData object
MyDataResource resource = cr.wrap(MyDataResource.class);
MyData myData = resource.retrieve();

I initially tested this in a standalone JSE class, and everything worked fine.
When I try to run the same thing in Android, the myData object is null. Any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

鲸落 2024-10-09 19:35:23

您可以在此处查看 Android 特性:
RESTLet android 页面

我花了几个小时在理解问题之前,您需要像这样显式注册 Jackson 转换器:

Engine.getInstance().getRegisteredConverters().add(new JacksonConverter());

You can check here the Android specificities:
RESTLet android page

I spent few hours before to understand the problem as well, you need to explicitly register the Jackson convertor like that :

Engine.getInstance().getRegisteredConverters().add(new JacksonConverter());
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文