【发布时间】:2014-09-01 14:38:56
【问题描述】:
我想用 Jersey 发送 Json。 我使用 mongoDb。
返回对象的函数:
public static List<DBObject> getAll(){
List<DBObject> toReturn = new ArrayList<DBObject>();
DBCollection coll = Db.databse.getCollection("Roles");
DBCursor cursor = coll.find();
try {
while(cursor.hasNext()) {
toReturn.add(cursor.next());
}
} finally {
cursor.close();
}
return toReturn;
}
还有我的球衣返回 json 的方法:
@GET
@Path("/")
@Produces(MediaType.APPLICATION_JSON)
public Response getAll(){
return Response.status(200).entity(Role.getAll()).build();
}
我使用邮递员。 POSTMAN 收到 200 但不是我的 JSON。 如果有人可以帮助我。 谢谢。
【问题讨论】:
标签: java json mongodb jersey dbobject