我尝试在 linux 中从 curl 调用 REST Web 服务,也使用 jersey
然后它返回
A message body reader for Java type, class mypackage.UserGroupsData, and MIME media type, application/json, was not found
Mappign 类是
public class UserGroupsData {
private int id;
private String name;
public int getId() {
return id;
} public void setId(int id) {
this.id = id;
}public String getName() {
return name;
}public void setName(String name) {
this.name = name;
} public int getId() {
return id;
}}
我的 POST 方法 ID
@POST
@Path("/getQualifiedNumbers")
@Produces("application/json")
@Consumes("application/json")
public Response getQualifiedNumbers(UserGroupsData userGroup){
return Response.status(201).entity(userGroup).build();
}
我曾经调用的卷曲命令是
curl -v -H "Accept: application/json" -H "Content-type: application/json" -X POST -d '{"id":"1","name":"e"}' http://localhost:8080/url/getQualifiedNumbers
服务器是码头
谢谢