This code works in a servlet:
PicasawebService service = new PicasawebService("Picasa test");
PicasawebClient picasaClient = new PicasawebClient(service);
List<AlbumEntry> albums = picasaClient.getAlbums("cgcmh1@gmail.com");
for(AlbumEntry album: albums){
resp.getWriter().println(album.getTitle().getPlainText());
List<PhotoEntry> photos = picasaClient.getPhotos(album);
req.setAttribute("photos", photos);
}
So I tried putting it in a Spring controller by using model.addAttribute
(below) instead of req.setAttribute
(above):
PicasawebService service = new PicasawebService("Picasa test");
PicasawebClient picasaClient = new PicasawebClient(service);
List<AlbumEntry> albums = picasaClient.getAlbums("cgcmh1@gmail.com");
for (AlbumEntry album : albums){
log开发者_如何学编程ger.warn("albums:" + album.getTitle().getPlainText());
List<PhotoEntry> photos = picasaClient.getPhotos(album);
model.addAttribute("photos", photos);
}
However, the Spring code fails to find any albums in Picasa while the servlet code finds them successfully.
Anyone know why this is the case?
In both cases they are using this version of the PicasawebClient and this version of the PicasawebService.
model.addAttribute("photos", photos);
will override the photos
attribute of the map on each iteration, so you will only be able to access the last album.
精彩评论