Version 9

    @Path and regular expressions

     

    The @Path annotation is not limited to simple path expressions.  You also have the ability to insert regular expressions into @Path's value.  For example:

     

    @Path("/resources)
    public class MyResource {
    
       @GET
       @Path("{var:.*}/stuff")
       public String get() {...}
    }
    

     

    The following GETs will route to the getResource() method:

     

    GET /resources/stuff
    GET /resources/foo/stuff
    GET /resources/on/and/on/stuff
    

     

    The format of the expression is:

     

    "{" variable-name [ ":" regular-expression ] "}"
    

     

    The regular-expression part is optional.  When the expression is not provided, it defaults to a wildcard matching of one particular segment.  In regular-expression terms, the expression defaults to

    "([]*)"
    

     

    For example:

     

    @Path("/resources//stuff")

     

    will match these:

     

    GET /resources/foo/stuff
    GET /resources/bar/stuff
    

     

    but will not match:

     

    GET /resources/a/bunch/of/stuff