users@jersey.java.net

[Jersey] Re: Trying to write a MessageBodyReader for application/x-www-form-urlencoded

From: George Sapountzis <gsapountzis_at_gmail.com>
Date: Wed, 2 Nov 2011 23:37:32 +0200

On Wed, Nov 2, 2011 at 8:45 PM, Jason Erickson <jason_at_jasonerickson.com> wrote:
> What I would like to do is something like this:
>
> @POST
> @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
> public void submitPerson(Person person) {
>        personDao.save(person);
> }
>
>
> There might be more to it, but that's the gist.  I tried to write a MessageBodyReader<Person> that consumes application/x-www-form-urlencoded, but the readFrom method simply takes an InputStream.  I was going to transform that into a MultivaluedMap<String, String> but that's turning out not to be very straightforward for me (I can't instantiate my own).  Is there something I'm missing? Do I just have to get down to the nuts and bolts of reading the InputStream and constructing my own map?
>
>

see https://github.com/gsapountzis/jersey-binding/blob/master/src/main/java/com/github/gsapountzis/jersey/binding/impl/provider/FormBeanProvider.java
for how to get the Form / MultivaluedMap<String, String> from the
InputStream.