users@jersey.java.net

Re: [Jersey] Uri matching

From: António Mota <amsmota_at_gmail.com>
Date: Thu, 26 Feb 2009 16:13:48 +0000

I have a slightly different scenario. I have

1) @GET
        @Path("/data/{key}")
        String read(@PathParam("key")String key);
        
2) @GET
        @Path("/data/{key}")
       String read(@PathParam("key")String key,
@QueryParam("mode")boolean mode);

How do I make to

/data/10001 -> match 1)

/data/10001?mode=xxx -> match 2)

Should I also use reegex?

Cheers.

_______________________________________________

Melhores cumprimentos / Beir beannacht / Best regards

António Manuel dos Santos Mota
_______________________________________________




2009/2/25 Bryon Jacob <bryon_at_jacobtx.net>:
> yes - you provide a regular expression to specify what matches each path
> param, so in your case you can say:
>
> @Path("/get/{query : .*}")
>
> and query will match everything after the get/
>
> (by default, the regex is something like [^/]*, so params match "everything
> up to the next slash".)
>
>
> On Feb 25, 2009, at 9:13 AM, Vyacheslav V. Zholudev wrote:
>
>> Hi!
>>
>> I'm a newbie to Jersey, so forgive me for a possibly trivial question. Is
>> there a way to match the rest of a @Path? For instance if I provide
>> @Path(/get/{query})
>> then when the url is like /get/foo/bar/doc
>> then 'query' variable will be matched to '/foo/bar/doc'?
>>
>> Thanks in advance,
>> Vyacheslav
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
>> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>
>