我使用简单的java和jersey进行休息。下面是方法。我从poster发送json请求,并希望在不声明POJO类的情况下将这些数据检索到方法中。但无法检索。
@Path("{entity}/markLabel")
@PUT
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public Response markLabel()
throws Exception {
}
我想将请求json参数(fileType,groupId,sourceId(检索到方法this request json参数中。
这是标题部分
有人能帮我吗?
为什么要在另一个方法中检索请求参数或标头?
一个方法处理一个请求,就是这样,但如果你想将功能的某个部分隔离到单独的方法中,你可以在请求处理方法中调用另一个方法。
@Path("{entity}/markLabel")
@PUT
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public Response markLabel(ReqObject String reqBody) throws Exception {
//////do something
someOtherMethod(reqBody);
//////do something
}
class ReqObject{
String fileType;
String groupId;
String sourceId;
//getters and setters
}