_at_FormParam (was Re: [Resteasy-developers] _at_QueryParam and POST)

From: Marc Hadley <Marc.Hadley_at_Sun.COM>
Date: Mon, 09 Jun 2008 11:31:30 -0400

On Jun 3, 2008, at 9:55 AM, Stephan Koops wrote:
> IMO JAX-RS should support @FormParam.
Unless anyone shouts loudly I'm going to add this annotation. It will
have the same targets as @QueryParam and will be usable with the same
Java types.

Unfortunately this will slightly complicate the rules for method
signatures since use of @FormParam will require the runtime to consume
the request body. I propose that you'll be able to use @FormParam in
conjunction with a MultivaluedMap<String, String> parameter that will
receive all of the form data but you won't be able to consume the body
with any other Java type. E.g. this will be ok:

public Response(@FormParam("foo") SomeType param)

this will also be OK:

public Response(@FormParam("foo") SomeType param,
MultivaluedMap<String, String> entireForm)

but this won't be allowed:

public Response(@FormParam("foo") SomeType param, String entireForm)

I'm also debating whether to add a method:

MultivaluedMap<String, String> Request.getFormParameters()

similar to the existing

MultivaluedMap<String, String> UriInfo.getQueryParameters()

Comments ?


> Bill Burke schrieb:
>> Yeah, we had a significant discussion about this on the JSR mail
>> list. The servlet specification makes no distinction between www-
>> form-urlencoded parameters and URI parameters. This is not the
>> case in JAX-RS. @QueryParam only works with URI parameters (/foo?
>> param=value).
>> The only way to get at form params is to use a MultivaluedMap as
>> your request representation.
>> @POST
>> public void post(MultivaluedMap<String, String> form) {...}
>> We had discussed introducing a @FormParam annotation, but I don't
>> think an agreement had been reached. If you think things need to
>> be changed, place voice your opinion on
>> (in copy).
>> Michael Martinsen wrote:
>>> Hello
>>> Reading the docs, it seems to me that the @QueryParam should also
>>> pick up params submitted using POST method.
>>> I have a simple example which works when using GET, but not using
>>> POST...
>>> Any thoughts on that?
>>> Thanks
>>> /Michael
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

Marc Hadley <marc.hadley at>
CTO Office, Sun Microsystems.