此代码在 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);
}
model.addAttribute
所以我尝试通过使用(下)而不是(上)将它放入 Spring 控制器中req.setAttribute
:
PicasawebService service = new PicasawebService("Picasa test");
PicasawebClient picasaClient = new PicasawebClient(service);
List<AlbumEntry> albums = picasaClient.getAlbums("cgcmh1@gmail.com");
for (AlbumEntry album : albums){
logger.warn("albums:" + album.getTitle().getPlainText());
List<PhotoEntry> photos = picasaClient.getPhotos(album);
model.addAttribute("photos", photos);
}
但是,Spring 代码无法在 Picasa 中找到任何相册,而 servlet 代码可以成功找到它们。
有谁知道为什么会这样?
在这两种情况下,他们都使用这个版本的 PicasawebClient和这个版本的 PicasawebService。