[color=red]1.迭代List(hql组装出来的对象)[/color]
hql:
String hql = "select (select b.rotaname from RunRota b where b.rotaid=a.rotaid),a.classid,a.classname from RunClass a where a.rotaid in "
+" (select c.rotaid from PlanRota c where "
+" c.startdate = (select max(b.startdate) from PlanRota b where b.factoryid="+runFactoryId+" and b.startdate < current_date) and c.factoryid="+runFactoryId+") order by a.orderno ";
在ACTION中设值:
request.setAttribute("classes", classes);
迭代方法:
[color=red]说明:这个时候是根据List的下标对值进行引用的[/color]
[color=red]2.迭代HashMap[/color]
在ACTION中设值,factories为一个构造好的HashMap:
在ACTION中设值:
request.setAttribute("factories",factories);
迭代方法:
[color=red]说明:这个时候是根据HashMap的key和value对值进行引用的[/color]
[color=red]1.迭代List(对应表记录)[/color]
这种情况最常见,也就是直接迭代我们从后台组装好的一条一条的记录对象
在ACTION中设值:
returnCards = returncardService.findReturnCard();
request.setAttribute("returnCards ",returnCards );
[color=red]说明:这个时候是根据对象的属性对值进行引用的[/color]
hql:
String hql = "select (select b.rotaname from RunRota b where b.rotaid=a.rotaid),a.classid,a.classname from RunClass a where a.rotaid in "
+" (select c.rotaid from PlanRota c where "
+" c.startdate = (select max(b.startdate) from PlanRota b where b.factoryid="+runFactoryId+" and b.startdate < current_date) and c.factoryid="+runFactoryId+") order by a.orderno ";
在ACTION中设值:
request.setAttribute("classes", classes);
迭代方法:
<select name="classId" style="width:140px">
<c:forEach var="class" items="${classes}">
<c:choose>
<c:when test="${runReturncardForm.classId==class[1]}">
<option value="${class[1]}" selected>
${class[0]}|${class[2]}
</option>
</c:when>
<c:otherwise>
<option value="${class[1]}">
${class[0]}|${class[2]}
</option>
</c:otherwise>
</c:choose>
</c:forEach>
</select>
[color=red]说明:这个时候是根据List的下标对值进行引用的[/color]
[color=red]2.迭代HashMap[/color]
在ACTION中设值,factories为一个构造好的HashMap:
在ACTION中设值:
request.setAttribute("factories",factories);
迭代方法:
<select name = "factoryid" id = "factoryid" style="width:138px">
<c:forEach var="factory" items="${factories}">
<option value="${factory.key}">
${factory.value}
</option>
</c:forEach>
</select>
[color=red]说明:这个时候是根据HashMap的key和value对值进行引用的[/color]
[color=red]1.迭代List(对应表记录)[/color]
这种情况最常见,也就是直接迭代我们从后台组装好的一条一条的记录对象
在ACTION中设值:
returnCards = returncardService.findReturnCard();
request.setAttribute("returnCards ",returnCards );
<c:forEach var="returnCard" items="${returnCards}">
<tr class="trbai">
<TD height="27" align="center" noWrap>${returnCard.returntime}</td>
<TD height="27" align="center" noWrap>
<c:forEach var="returnerName" items="${returnerNameMap}">
<c:if test="${returnCard.returner == returnerName.key}">
${returnerName.value}
</c:if>
</c:forEach>
</td>
<TD height="27" align="center" noWrap>
${returnCard.cardcode}
</td>
<TD height="27" align="center" noWrap>
<a href="javascript:dispDetail('${returnCard.tid}');" >查看详细</a>
</td>
</tr>
</c:forEach>
[color=red]说明:这个时候是根据对象的属性对值进行引用的[/color]