for (int k = 0; k < list.size(); k += 2) {
if (((k + 1) % 2) != 0) {
m1 = (MealEntity) list.get(k);
%>
<tr>
<td>
<a href="MealServlet?type=findbyid&mid=<%=m1.getMealId()%>"><img
src="mealImg/<%=m1.getMealImage()%>.jpg" width="148"
height="126" border="0" /> </a>
</td>
<td>
<div>
<%=m1.getMealId()%>
:
<%=m1.getMealName()%>
<br />
<span style="text-decoration: line-through; color: gray;">原价:人民币<%=m1.getMealPrice()%>元</span>
<br />
现价:人民币
<%=m1.getMemberPrice()%>
元
</div>
<a href="MealServlet?type=findbyid&mid=<%=m1.getMealId()%>"><img src="images/detail_cn.gif" border="0" width="60" height="20" /></a>
<a href="ShoppingCartServlet?type=add&mid=<%=m1.getMealId() %>"><img src="images/buy_cn.gif" border="0" width="60" height="20" /></a>
</td>
<%
if (k == list.size() - 1) {
break;
}
if (k < list.size() - 1) {
m2 = (MealEntity) list.get(k + 1);
} else {
break;
}
}
%>
<td>
<a href="MealServlet?type=findbyid&mid=<%=m2.getMealId()%>"><img
src="mealImg/<%=m2.getMealImage()%>.jpg" width="148"
height="126" border="0" /> </a>
</td>
<td>
<div>
<%=m2.getMealId()%>
:
<%=m2.getMealName()%>
<br />
<span style="text-decoration: line-through; color: gray;">原价:人民币<%=m2.getMealPrice()%>元</span>
<br />
现价:人民币
<%=m2.getMemberPrice()%>
元
</div>
<a href="MealServlet?type=findbyid&mid=<%=m2.getMealId()%>"><img src="images/detail_cn.gif" border="0" width="60" height="20" /></a>
<a href="ShoppingCartServlet?type=add&mid=<%=m2.getMealId() %>"><img src="images/buy_cn.gif" border="0" width="60" height="20" /></a>
</td>
利用+=n连续保存或者输出n个数,布布扣,bubuko.com