示例#1
0
 @GET
 @Path("users")
 // JSON: include "application/json" in the @Produces annotation to include json support
 @Produces({"application/json"})
 // @Produces({ "application/xml" })
 public Map<String, List<User>> getUsersMap() {
   Map<String, List<User>> result = new HashMap<String, List<User>>();
   result.put("users", userDao.getAll());
   return result;
 }
示例#2
0
  private User getUser(Long id) {
    for (User user : userDao.getAll()) if (user.getId().equals(id)) return user;

    throw new WebApplicationException(Response.Status.NOT_FOUND);
  }