我想把一个集合查出来利用list.add加入新的一个集合,并传到web页面,问题是数据库明明有记录,但就是报空指针
如果改成list().get(i).get属性名,却不会错了,请各位大哥帮忙
List symptom=null;
List benefit=null;
for (int i=0; i<foodlist.size() ;i++)
{
Food food = (Food)foodlist.get(i);
for(int j=0;j<foodDao.searchfood1(food.getFood1()).size();j++){
System.out.println(foodDao.searchfood1(food.getFood1()).size());
symptom.add(foodDao.searchfood1(food.getFood1()).get(j));
System.out.println(foodDao.searchfood1(food.getFood1()).get(j).getFood2());
}
------解决方案--------------------
List symptom=new ArrayList();