这是类(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";
}
}
它给出了这个错误
子资源定位器 public java.lang.String com.bablo.rest.Library.geBook(java.lang.String) 不能有实体参数。尝试将参数移动到相应的资源方法中。
和
索引 0 处的参数处缺少方法 public java.lang.String com.bablo.rest.Library.getBook(java.lang.String) 的依赖项
我通过浏览器调用这个网络服务,如下所示
http://localhost:8080/JAXRS-HelloWorld/rest/books/bablo
我也在做curl:
curl -X GET http://localhost:8080/JAXRS-HelloWorld/rest/books/bablo
最佳答案
您需要在方法上方添加 @POST
或 @GET
标签。
关于java - 我在这个 Jersey Java 类中做错了什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25088242/