On Mon, Apr 21, 2008 at 6:57 PM, Martin Probst <mail_at_martin-probst.com> wrote:
> Ideally, I'd like my book collection to reside on "/books/" and my single
> books to reside on "/book/12". Is that possible with JSR311 annotations? Can
> I refer to a parent path e.g. by "../book/{bookId}"? Or is this better
> served by a different implementation pattern?
this could be achived like this
@Path("/")
public class SomeResource {
@GET
@Path("books/")
public List<Book> getBooks() {
:
}
@GET
@Path("book/{id}")
public Book getBook(@PathParam("id") String bookId) {
:
}
}
although I would not recommend that approach. Think a bit about how
your resource are going to be used - i.e:
1) Get all books: /books/
2) From the list of books show detailed info about a particular one: /books/42
this could be modeled in one logical resource without resolving to map
directly from the root ("/").
--
Lars Tackmann
--
Yours sincerely
Lars Tackmann