我注意到,当我用Response.status(201).entity(id).build
,它返回以下错误时:错误试图返回一个整数作为实体
严重:MessageBodyWriter找不到媒体类型=应用程序/ JSON,类型=级Java。 lang.Integer,genericType = class java.lang.Integer。
@POST
@Produces({"application/json"})
public Response createUser(
@NotNull @FormParam("username") String username,
@NotNull @FormParam("password") String password,
@NotNull @FormParam("role") String role) {
int id = 12;
return Response.status(201).entity(id).build();
}