users@jersey.java.net

Re: [Jersey] Regular Expression matching any

From: John Ament <my.reprive_at_gmail.com>
Date: Wed, 16 Jun 2010 17:16:13 -0400

Yep, I realized that right after I sent the email. Silly me. Thanks
though!

John

On Wed, Jun 16, 2010 at 10:36 AM, Paul Sandoz <Paul.Sandoz_at_sun.com> wrote:

> Hi John,
>
> Regular expressions are supported when declaring path parameters. So you
> will need to do something like this:
>
> @Path("page/{page: .+}") // JAX-RS reuses a subset of the URI template
> syntax.
> public class MyResource {
> @PathParam("page") String page;
> }
>
> See:
>
>
> https://jsr311.dev.java.net/nonav/releases/1.1/javax/ws/rs/Path.html#value%28%29
>
> You can enable tracing and logging in Jersey and you should see what the
> generated regular expressions are in trace headers of the response:
>
> <init-param>
> <param-name>com.sun.jersey.config.feature.Trace</param-name>
> <param-value>true</param-value>
> </init-param>
> <init-param>
>
> <param-name>com.sun.jersey.spi.container.ContainerRequestFilters</param-name>
>
> <param-value>com.sun.jersey.api.container.filter.LoggingFilter</param-value>
> </init-param>
> <init-param>
>
> <param-name>com.sun.jersey.spi.container.ContainerResponseFilters</param-name>
>
> <param-value>com.sun.jersey.api.container.filter.LoggingFilter</param-value>
> </init-param>
>
> Paul.
>
>
> On Jun 16, 2010, at 2:46 PM, John Ament wrote:
>
> I've run into an issue, and I'm not sure what I missed. I created a
>> JAX-RS service that i want to match anything that matches page/(.+)
>>
>> So I added this to my class level:
>>
>> @Path("page/(.+)")
>> @RequestScoped //CDI enabled
>>
>> and method level:
>>
>> @GET
>> @Produces("application/json")
>> public JSONObject getPage() throws JSONException {
>>
>> When it deploys, jersey finds no matches. No indication that the service
>> was invoked.
>>
>> Thanks!
>>
>> John
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>
>