I have this code method in a java class with JAX-RS:
import javax.ws.rs.GET;
import javax.ws.rs.HeaderParam;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.Response;
@Path("/reports/{id: (zerotrips|notrips|tripsummary|rejectedtrips){1}/{0,1}}")
@GET
public Response get(@Context HttpServletRequest aRequest){
....
}
Could someone give some examples of the url mapped by the expression in the @Path annotation?
Replace
zerotripswith any of the other ones on between the parenthesisThis says any one of the values in the parenthesis.
|means "or". The{1}means "once".means with or without a slash.
{0,1}means zero to once.A pattern followed by
{}gives the number of times it is allowed. For examplea{3,5}means anathree to five times. So the following would match:aaa,aaaa,aaaaa, butaawould not match.