没有图片我应该返回什么?

时间:2018-03-21 08:56:45

标签: java api response javax.ws.rs

我有一个API。

@GET
@Path("picture")
@Produces("image/jpeg")
Response getPicture(@QueryParam("key") String key);

相应的服务。

@Override
public Response getPicture(String key) {
    try{
        byte[] image = service.getPicture(key);
        if (image == null) {

        }
        return Response.ok(new ByteArrayInputStream(image)).build();
    } catch (Exception e) {

    }
    return null;
}

我尝试返回null并返回Response.ok(new ByteArrayInputStream(null))。build(),但我会得到一个异常。

当图像为空时,此方法会返回什么?

0 个答案:

没有答案
相关问题