Hi

sorry for a late response

when you do 

@FormParam("") Apple apple

then what it means is that all the application/www-url-form-encoded sequence
is injected (name/value pairs) into an Apple instance.

So if you'd like to have them all injected into a map then simply do

@Path("/")
@Consumes("application/www-url-form-encoded")
public Response addApple(MultivaluedMap<String,String> apple) {}

MultivaluedMap should really be used in such cases, as it can hold multiple
values for a given field key/name; @FormParam can be handy when accessing an
individual form field value, though @FormParam("") can indeed be used to
collect them all and inject into the bean.

cheers, Sergey


Sam.Wang wrote:
> 
> Hello all:
> 
> I have a question about parameter mapping. 
> It works fine when I mapped parameters to customized object. but if I
> changed the Hashtable or Hashmap, it doesn't work at all. 
> I searched in google and most results tell me it doesn't support Map type
> in JAXB, but I have some special reason to do that in using map way.
> So could everyone can give some suggestions or advices about that?
> thanks:)
> 
> @POST
>       @Path("/")
>       public Response addApple(@FormParam("") Apple apple) throws Exception;
> 
> I hope it can work when I changed the Apple to Hashtable.
> 
> @POST
>       @Path("/")
>       public Response addApple(@FormParam("") Hashtable<String,String> apple)
> throws Exception;
> passed the  hashtable object is null.
> 

-- 
View this message in context: 
http://www.nabble.com/how-to-map-parameters-to-hashtable-or-hashmap-in-REST.-tp25884722p25916797.html
Sent from the cxf-user mailing list archive at Nabble.com.

Reply via email to