@RequestMapping(value="/allGoods")publicModelAndViewgoods(HttpServletRequestrequest){Usercur_user=(User)request.getSession().getAttribute("cur_user");IntegeruserId=cur_us...
@RequestMapping(value = "/allGoods")
public ModelAndView goods(HttpServletRequest request) {
User cur_user = (User)request.getSession().getAttribute("cur_user");
Integer userId = cur_user.getId();
List goodsList = goodsService.getGoodsByUserId(userId);
List goodsAndImage = new ArrayList();
for (int i = 0; i < goodsList.size() ; i++) {
//将用户信息和image信息封装到GoodsExtend类中,传给前台
GoodsExtend goodsExtend = new GoodsExtend();
Goods goods = goodsList.get(i);
List images = imageService.getImagesByGoodsPrimaryKey(goods.getId());
goodsExtend.setGoods(goods);
goodsExtend.setImages(images);
goodsAndImage.add(i, goodsExtend);
}
ModelAndView mv = new ModelAndView();
mv.addObject("goodsAndImage",goodsAndImage);
mv.setViewName("/user/goods");
return mv;
}
}
为什么用数据库调用不了图片
展开