使用Resty GWT在GET中使用byte []

时间:2018-08-13 13:46:53

标签: gwt jax-rs resty-gwt

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

@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 []?

1 个答案:

答案 0 :(得分:0)

对我有用的解决方案是创建一个byteResponse类,其中byte []数组是attribute。那么该类现在是serverSide中getImage的返回类型,并且是gwt侧methodeCallback内部的类型。