users@jersey.java.net

[Jersey] Re: POST parameters not injected via MultivaluedMap

From: John Lister <john.lister_at_kickstone.com>
Date: Wed, 08 Jun 2011 07:30:04 +0100

On 06/03/2011 09:24 AM, harold.capitaine_at_gmail.com wrote:
> Hi all,
>
> First of all, I'm using Jersey 1.7 on GAE (Google Apps Engine).
> My goal is to get all parameters from a POST request as a parameter of
> a mapped method.
> I read the doc and it's writing to use this:
> @POST
> @Consumes("application/x-www-form-urlencoded")
> public void post(MultivaluedMap<String, String> formParams) {
> // Store the message
> }
>
> But in my case, the variable formParam is always an empty map.
> I also read that all values need to be Strings but mines are.
>
> So do I need to configure anything special for example in the web.xml
> or somewhere else to make it works.

Not sure about GAE but there used to be (although sure it is still the
case) with glassfish in that the servlet container would consume the
post data such that if you asked for a map of values it would be empty
unless you explicitly asked for a @FormParam value as well. In fact you
can add a dummy param to force the map to be filled, giving:

public void post(MultivaluedMap<String, String> formParams,
@FormParam("dummy") String dummy) {

John

---
www.pricegoblin.co.uk