Jersey Client 可以自动将 POJO 实体编码到 application/x-www-form-urlencoded 中,还是需要编写自定义 MessageBodyWriter?

发布于 2024-11-29 02:43:03 字数 529 浏览 3 评论 0原文

我正在使用 Jersey 的 Client类与 Jackson 一起处理与 JSON 的序列化。我还使用 JSONConfiguration.FEATURE_POJO_MAPPING 设置让 Jackson 自动将我的 POJO 序列化为 JSON。

我发送 POJO 的远程服务使用 MediaType.APPLICATION_FORM_URLENCODED 并生成 MediaType.APPLICATION_JSON_TYPE

我是否必须创建自己的 MessageBodyWriter 实现来处理 POJO 序列化到 application/x-www-form-urlencoded 中,或者 Jersey 是否提供了一个实现来为我执行此操作我的 POJO 注释?

I am calling a RESTful web service using Jersey's Client class along with Jackson to handle serialization to/from JSON. I am also using the JSONConfiguration.FEATURE_POJO_MAPPING setting to have Jackson automatically serialize my POJOs to JSON.

The remote service I'm sending my POJO to consumes MediaType.APPLICATION_FORM_URLENCODED and produces MediaType.APPLICATION_JSON_TYPE.

Do I have to create my own MessageBodyWriter implementation to handle POJO serialization into application/x-www-form-urlencoded, or does Jersey provide an implementation that does this for me using my POJO annotations?

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

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

发布评论

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

评论(1

再浓的妆也掩不了殇 2024-12-06 02:43:03

Jersey does not have a support for converting arbitrary POJO's to application/x-www-form-urlencoded. It can convert instances of Form, or MultivaluedMap. So either your method would have to return one of these, or you will have to write your own MessageBodyWritter.

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