0
这个代码在一个servlet:为什么相同的代码在servlet中工作,但不在Spring控制器中工作?
PicasawebService service = new PicasawebService("Picasa test");
PicasawebClient picasaClient = new PicasawebClient(service);
List<AlbumEntry> albums = picasaClient.getAlbums("[email protected]");
for(AlbumEntry album: albums){
resp.getWriter().println(album.getTitle().getPlainText());
List<PhotoEntry> photos = picasaClient.getPhotos(album);
req.setAttribute("photos", photos);
}
于是,我把它放在一个Spring控制器使用model.addAttribute
(下同),而不是req.setAttribute
(上图):
PicasawebService service = new PicasawebService("Picasa test");
PicasawebClient picasaClient = new PicasawebClient(service);
List<AlbumEntry> albums = picasaClient.getAlbums("[email protected]");
for (AlbumEntry album : albums){
logger.warn("albums:" + album.getTitle().getPlainText());
List<PhotoEntry> photos = picasaClient.getPhotos(album);
model.addAttribute("photos", photos);
}
然而,春节代码无法在Picasa中找到任何相册,而servlet代码发现它们成功。
任何人都知道为什么是这样的情况?
在这两种情况下,他们正在使用this version of the PicasawebClient和this version of the PicasawebService。
您的JSP看起来像什么?你的Spring配置是什么样的? – skaffman 2011-02-17 23:02:23