Reputation: 292
I have a problem with Jersey and Grizzly. The problem could be very basic but I am struggling to solve it. The idea is that I am creating an exercise application that needs to store books. Everything seems to be alright but it does not work as expected. Here is the source code:
@Path("/books")
public class BooksResource
{
private BookDao bookDao= new BookDao();
@GET
@Produces(MediaType.APPLICATION_JSON)
public Collection<Book> getBooks()
{
return (bookDao.getBooks());
}
@Path("/{id}")
@GET
@Produces(MediaType.APPLICATION_JSON)
public Book getBook(@PathParam("id")String id)
{
Book book = bookDao.getBook(id);
return (book);
}
As can be observed, the path /books is working perfectly but the problem is that id is always null and it shouldn't be. Does anyone know where the problem comes from?
Upvotes: 0
Views: 68
Reputation: 37023
Try removing "/" from the path and it should work.
From
@Path("/{id}")
To
@Path("{id}")
Upvotes: 1