gwt - 使用 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[] ?
解决方案
对我有用的解决方案是创建一个 byteResponse 类,其中 byte[] 数组是一个属性。那么这个类现在是 serverSide 中 getImage 的返回类型和 gwt 端 methodeCallback 中的类型。
推荐阅读
- android - 如何以编程方式将焦点从一个 EditText 字段更改为下一个 EditText 字段?
- python - 在 R 中打开一个腌制的 sklearn 文件
- reactjs - useState 的值因数组而异
- swift - 是否可以在枚举关联值条件和另一个枚举案例之间编写复合开关案例?
- html - 仅使用 CSS 调整基于窗口的图像大小时的空白
- python - 将数据附加到 csv 文件中
- azure - Azure 构建管道 - 暂停和启用 DefinitionQueueStatus 更改 REST API
- email - Magento 1.9 - 将订单管理电子邮件发送到不同的电子邮件地址
- python - 将 matplotlib 文件保存为 png 时缺少 Y 轴标签
- r - 是否有用于检查指定 GeoJSON 对象(多边形或多多边形)是否包含指定点的 R 函数?