public ActionForward getChkErrorList(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
String hql = "select sfpd.providerCode,sfpd.subsOrderNo,sfpd.ticketNo," +
"sfpd.noticeDate,sfpd.ticketPrice,sce.errorType " +
" from SlmtFlightProviderData sfpd ,SlmtChkError sce where sfpd.id = sce.providerDataId ";
List<ChkErrorVo> list = this.ctrl.getListAll(hql);
String message = "";
if(list.isEmpty() || list.size() == 0){
log.info("没查到与供应商的差错数据!");
message = "没查到与供应商的差错数据!";
request.setAttribute("message", message);
}
log.info("查到 的数据个数为:["+list.size()+"]");
request.setAttribute("list", list);
return mapping.findForward("list");
}
如上的一个方法,查询结果是两个表中的若干字段,结果集是一个list,如何遍历整个list中的每个值,以表格的形式显示在页面。要说的是页面的遍历标签 <logic:iterate id="l" name="list"> 或者 foreach 标签遍历的一条数据都是一个对象,有一个实体想对应,而现在list中每一条数据都没一个实体相对,如何遍历。请指教。
for (Object[] obj : list) {
String name = (String) obj[0];
Date date = (Date) obj[1];
int type = (Integer) obj[2];
},Are you OK???
<foreach var="ls" items="${list}">
${ls[字段名]}
</foreach>