2

我正在与 Jersey 和 Grizzly 一起开发 WebApp。

我想通过给客户提供图像imageIDimageURL. 客户也应该有可能向我发送图像。那么如何使用 grizzly 托管图像呢?以及该方法应该如何@POST

编辑 现在我知道@POST 方法应该是什么样子了。这有助于:如何将通用文件发送到球衣服务并正确接收? 但还有一个问题。如何使用 grizzly 托管图像并提供指向它的链接。

编辑 现在我也知道如何托管图像。http://jersey.java.net/nonav/documentation/latest/jax-rs.html#d4e322 Rest 为我做这个。

  1 @GET
  2 @Path("/images/{image}")
  3 @Produces("image/*")
  4 public Response getImage(@PathParam("image") String image) {
  5     File f = new File(image);
  6 
  7     if (!f.exists()) {
  8         throw new WebApplicationException(404);
  9     }
 10 
 11     String mt = new MimetypesFileTypeMap().getContentType(f);
 12     return Response.ok(f, mt).build();
 13 }
4

0 回答 0