users@jsr311.java.net

leading / in Path URI template

From: Bertold Kolics <Bertold.Kolics_at_Sun.COM>
Date: Fri, 30 May 2008 15:32:16 -0500

[ Excuse me if this has been asked before ]

The JSR311 draft does not show any examples with the leading / in the
URI template of Path annotations. Most of the samples in the Jersey
codebase, however, have a leading / in the URI template.

Does the leading slash in the path have any effect? If so, does it
change how the path is computed when using a leading slash in sub resources?

For example,
- is the URI template at line 9 valid?
- what should that resolve to if the base context of my application is
http://example.com:8080/myrestapp? Should it resolve to
http://example.com:8080/myrestapp/{id} or
http://example.com:8080/myrestapp/widgets/{id}?

Thanks for the clarification.

Bertold


1 @Path("widgets")
2 @ProduceMime("application/xml")
3 public class WidgetsResource {
4
5 @GET
6 public String getAll() {...}
7
8 @GET
9 @Path("/{id}")
10 public Widget getWidget(@UriParam("id") String id) {...}
11
12 @GET
13 @Path("{id}/description")
14 @ProduceMime("text/html")
15 public String getDescription(@UriParam("id") String id) {...}
16 }