Jersey Client 可以自动将 POJO 实体编码到 application/x-www-form-urlencoded 中,还是需要编写自定义 MessageBodyWriter?
我正在使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Jersey 不支持将任意 POJO 转换为 application/x-www-form-urlencoded。它可以转换 Form< 的实例/a>,或多值映射。因此,要么您的方法必须返回其中之一,要么您必须编写自己的 MessageBodyWritter。
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.