Here is the class :-
package com.bablo.rest;
import javax.websocket.server.PathParam;
import javax.ws.rs.Path;
@Path("/")
public class Library {
@Produces("text/plain")
@Path("/books/{name}")
public String getBook(@PathParam("name") String name){
System.out.println(name);
return "My Name is Anthony Goncalves";
}
}
Its giving this as error
A sub-resource locator, public java.lang.String com.bablo.rest.Library.geBook(java.lang.String), can not have an entity parameter. Try to move the parameter to the corresponding resource method.
and
Missing dependency for method public java.lang.String com.bablo.rest.Library.getBook(java.lang.String) at parameter at index 0
I am invoking this webservice through the Browser like this
http://localhost:8080/JAXRS-HelloWorld/rest/books/bablo
Also I am doing curl:
curl -X GET http://localhost:8080/JAXRS-HelloWorld/rest/books/bablo
You need to add tag either @POST
or @GET
above your method.
I believe you meant to use
javax.ws.rs.PathParam
rather than
javax.websocket.server.PathParam
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With