首页 > 解决方案 > 使用 resty GWT 在 GET 中使用 byte[]

问题描述

在我的服务器端,我有以下内容:

@ApiOperation(value = "myValue", tags = "{mytag}")
@GET
@Path("mypath")
@Produces("image/jpeg")
public Response getImage(@ApiParam(hidden = true) @HeaderParam("Accept-Language") String acceptLanguage,
        @ApiParam(hidden = true) @HeaderParam("accountId") Long accountId,
        @PathParam("var1Id") Long var1, @PathParam("imageId") Long documentId,
        @PathParam("var2Id") Long var2Id) throws SyncException {
    return Response.ok(ImageService.getImage(acceptLanguage, ImageId)).build();
}

其中 getImage 返回类型为 byte[] 。

在我的客户端并使用 resty GWT 我有以下内容:

@GET
@Path(mypath)
@Produces("image/jpeg")
public void getImage( @PathParam("var1Id") Long var1id, @PathParam("var2Id") Long var2Id , @PathParam("imageId") Long imageId, MethodCallback<T> callback);

我的问题是我应该在 MethodeCallback 中放入什么才能使用服务器端发送的 byte[] ?

标签: gwtjax-rsresty-gwt

解决方案


对我有用的解决方案是创建一个 byteResponse 类,其中 byte[] 数组是一个属性。那么这个类现在是 serverSide 中 getImage 的返回类型和 gwt 端 methodeCallback 中的类型。


推荐阅读