开发者

Can Jersey Client automatically encode POJO entities into application/x-www-form-urlencoded, or do I need to write custom MessageBodyWriter?

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 re开发者_如何学运维mote 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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜