List集合取值问题
Action()方法
List list= service.queryApplySta(queryApplyStatusDto); //queryApplyStatusDto给sql传入的参数
queryApplySta()方法
QueryApplyDao dao = (QueryApplyDao) context.getBean("queryApplyDao");
List<QueryApplyStatusDto> list = dao.queryApplySta(queryApplyStatusDto);
return list
queryApplySta()方法中就学了和数据库交互取值后直接return
其中QueryApplyDao是实体类,例如包含 name、address、email
我要在Action()中拿到list中name的值,我该怎么遍历。
新手求教 list List Action 类 遍历
[解决办法]
for(QueryApplyStatusDto obj : list) {
obj.getName()
}
List<QueryApplyStatusDto> queryList = (QueryApplyStatusDto)service.....
for(int i=0;i<list.size(),i++){
QueryApplyStatusDto dto = (QueryApplyStatusDto)list.get(i);
System.out.println(dto.getName());
}