users@jersey.java.net

[Jersey] _at_PathParam optional components.

From: Praveen Cherukuri <praveen.cherukuri_at_gmail.com>
Date: Sun, 23 Oct 2011 01:00:27 -0400

Hello All,

I have a method annotated with something like

@Path("/service/animal:{animal}/type:{type}")
public void doStuff(@PathParam("animal") String animal, @PathParam("type")
String type)) {
.....
}

The above seems to work. Now, I would like to make "type:{type}" part of the
URI optional. So I was trying to do something like below. It's ok if the
method variable is assigned null.

@Path("/service/animal:{animal}/(type:{type})?")
public void doStuff(@PathParam("animal") String animal, @PathParam("type")
String type)) {
.....
}

But this doesn't seem to work. Any ideas on how this can be accomplished? I
think MatrixParameters are an option. But I don't want to pursue that if I
don't have to.

Thanks in advance for your response.

Regards,
Praveen.