我附加到一个列表,然后将该列表放入下面的函数中:
List<ItemBean> itemList;
for (Object bean : beans)
{
if (!bean.getItem().isActive())
{
itemList.add(bean.getItem().getId());
}
}
if (!itemList.isEmpty())
{
// Source of Supply List
buildItemList( request, commonDAO, false );
}
else{
buildItemFilterList( request, commonDAO, itemList);
}
但我在这里得到“只能迭代数组或 java.lang.Iterable 的实例”错误:
protected final List<ItemBean> buildItemFilterList( HttpServletRequest request,
CommonDAO dao,
ItemBean list
)
throws Exception
{
List<ItemBean> itemList = dao.getAllItems( false );
ItemBean item;
for (ItemBean s: list ) <<<<<-----ERROR!!!!!!!!!!!
{
item = dao.getItemById(s.getId());
itemList.add(item);
}
Collections.sort( itemList );
request.setAttribute("itemList", itemList);
return itemList;
}