我注意到,當我用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();
}