views:

44

answers:

1

Hi,

is it possible to configure GET method to read variable number of URI parameters and interpret them either as variable argument (array) or collection? I know query parameters can be read as list/set but I can't go for them in my case.

E.g.:

@GET
@Produces("text/xml")
@Path("list/{taskId}")
public String getTaskCheckLists(@PathParam("taskId") int... taskId) {
    return Arrays.toString(taskId);
}

Thanks in advance

+1  A: 

If I understand your question correctly, the @Path annotation can take a regular expression to specify a list of path components. For example, something like:

@GET
@Path("/list/{taskid:.+}")
public String getTaskCheckLists(@PathParam("taskid") List<PathSegment> taskIdList) {
    ......
}

There's a more extensive example here.

Dave Ray
Thanks, this is probably the closest I'll get to that so now I just need to put there regexp that matches numbers and slashes for example.com/ws/list/1 or example.com/ws/list/1/2/3/4/5/6
Zeratul