我正在使用localhost:8080/_ah/api/explorer google explore:我一直在获取
{
"error": {
"message": "com.google.appengine.repackaged.org.codehaus.jackson.map.JsonMappingException: Can not construct instance of javax.servlet.http.HttpServletResponse, problem: abstract types can only be instantiated with additional type information\n at [Source: N/A; line: -1, column: -1]",
"code": 400,
"errors": [
{
"domain": "global",
"reason": "badRequest",
"message": "com.google.appengine.repackaged.org.codehaus.jackson.map.JsonMappingException: Can not construct instance of javax.servlet.http.HttpServletResponse, problem: abstract types can only be instantiated with additional type information\n at [Source: N/A; line: -1, column: -1]"
}
]
}我的Google SPI代码是:
@ApiMethod(name = "findBillImage", httpMethod = ApiMethod.HttpMethod.GET )
public void findImage(HttpServletResponse httpServletResponse , @Named("blobkey") String blobKeyValue) throws IOException {
BlobKey blobKey = new BlobKey( blobKeyValue );
BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService();
blobstoreService.serve(blobKey, httpServletResponse);
}每当我尝试向HttpServletResponse写入任何内容时,都会收到此错误。我不明白为什么我不能写入httpServletResponse
发布于 2016-08-15 15:34:37
所以。对我来说,答案实际上是“设计”。
由于我使用谷歌应用引擎实现了"REST“,所以我不应该修改HttpResponse来返回”图像“。
因此,将图像“服务”回HttpResponse并不理想。我应该直接将带有存储URL的映像公开给客户端。
https://storage.cloud.google.com/myapp.appspot.com/20160603_154924.jpg我不能说我“100%”喜欢这个答案,但从我读到的内容来看,我相信这是正确的。
https://stackoverflow.com/questions/38948514
复制相似问题