使用 gridFSDBFile 有一种简单的方法可以做到这一点,但现在不再如此。
//This used to return a GridFSDBFile type. Returns GridFSFile now.
GridFSFile gridFsFile = gridFsTemplate.findOne(new Query(Criteria.where("_id").is(idTemp)));
//And would be done this way. Not anymore.
gridFSFile.writeTo(outputstream)
主要目标是返回保存在数据库中的图像以将其显示在 html 页面上,如下所示。
response.getOutputStream().write(outputstream.toByteArray());
response.getOutputStream().close();
猛跑小猪
桃花长相依
相关分类