我有这个服务器代码:
@Path("/saveE2eResult")
@POST
@Consumes(MediaType.APPLICATION_JSON + ";charset=utf-8")
@Produces(MediaType.APPLICATION_JSON + ";charset=utf-8")
public void saveE2eResult(E2eResults e2eResult) {
System.out.println("saved "+e2eResult.toString());
}
和
public enum E2eResults {
SUCCESS("Success"),
FAIL("Fail");
private final String name;
private E2eResults(String s) {
name = s;
}
@JsonCreator
public static E2eResults getEnumFromValue(String value) {
for (E2eResults e2eResult : values()) {
if (e2eResult.equalsName(value)) {
return e2eResult;
}
}
throw new IllegalArgumentException();
}
public boolean equalsName(String otherName) {
// (otherName == null) check is not needed because name.equals(null) returns false
return name.equals(otherName);
}
public String toString() {
return this.name;
}
}
我尝试调用curl并获取:
I curl -H "Content-Type: application/json" -X POST -d '{"e2eResult":"SUCCESS"}' http://localhost:8083/sdk/saveE2eResult
无法构造com.w.sdkService.operations.uiDto.E2eResults的实例,问题:null 在[来源:org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$UnCloseableInputStream@1a81d811; line:1,column:1]%
我该如何解决这个问题?