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:
@POST
@ConsumeMime("application/x-www-form-urlencoded")
public Response(@FormParam("foo") SomeType param)
this will also be OK:
@POST
@ConsumeMime("application/x-www-form-urlencoded")
public Response(@FormParam("foo") SomeType param,
MultivaluedMap<String, String> entireForm)
but this won't be allowed:
POST
@ConsumeMime("application/x-www-form-urlencoded")
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 ?
Marc.
>
> 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 users_at_jsr311.dev.java.net
>> (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: users-unsubscribe_at_jsr311.dev.java.net
> For additional commands, e-mail: users-help_at_jsr311.dev.java.net
>
---
Marc Hadley <marc.hadley at sun.com>
CTO Office, Sun Microsystems.