我需要根据ResponseEntity返回一个对象列表。我知道,我目前只是列表中的最后一个对象,但我需要一个完整的列表。想法?
@RequestMapping(path = "findAllPhotosByPhotoAlbumTitle", method = RequestMethod.GET)
@ResponseBody
public ResponseEntity<InputStreamResource> findAllPhotosByPhotoAlbumTitle(@PathVariable(value = "albumTitle") String albumTitle) throws IOException {
final List<Photo> allPhotosByPhotoAlbumTitle = photoService.findAllPhotosByPhotoAlbumTitle(albumTitle);
ResponseEntity<InputStreamResource> body = null;
for (Photo photo : allPhotosByPhotoAlbumTitle) {
body = ResponseEntity.ok()
.contentLength(photo.getMultipartFile().getSize())
.contentType(MediaType.parseMediaType(photo.getMultipartFile().getContentType()))
.body(new InputStreamResource(photo.getMultipartFile().getInputStream()));
}
return body;
}