Version 3

    Advaned @PathParam

     

    There are a few more complicated uses of @PathParams not discussed in the previous section.

     

     

    Multiple params per URI segment

     

    You are allowed to specify one or more path params embedded in one URI segment.  Here are some examples:

     

    1. @Path("/aaa{param}bbb")
    2. @Path("/{name}-{zip}")
    3. @Path("/foo{name}-{zip}bar")
    

     

    So, a URI of "/aaa111bbb" would match 1.  "/bill-02115" would match 2.  "foobill-02115bar" would match 3.

     

    Path params and regular expressions

     

    We discussed before how you can use regular expression patterns within @Path values.

     

    
    @GET
    @Path("/aaa{param:b+}/{many:.*}/stuff")
    public String getIt(@PathParam("param") String bs, @PathParam("many") String many) {...}
    
    

     

    For the following requests, lets see what the values of the "param" and "many" @PathParams would be:

     

    Request

    param

    many

    GET /aaabb/some/stuff

    bb

    some

    GET /aaab/a/lot/of/stuff

    b

    a/lot/of