最近在做一个类似商城的东西
将数据库中的数据集取到List中。在jsp页面中用for each来输出
只能做到一行一个的输出
如#
#
#
#
#
我想做到可以设定一行输出几个,超出就换行的效果
如
一行5个
# # # # #
# # # # #
# # # # #
# # #的效果,不知道怎么实现
请大家帮忙
将数据库中的数据集取到List中。在jsp页面中用for each来输出
只能做到一行一个的输出
如#
#
#
#
#
我想做到可以设定一行输出几个,超出就换行的效果
如
一行5个
# # # # #
# # # # #
# # # # #
# # #的效果,不知道怎么实现
请大家帮忙
数据:${obj} <c:if test="${((i.index + 1)%5) eq 0}"><br></c:if>
</c:forEach>
我的Product类
{
photopath
product_name
product_price
}
在struts 的action中从所有数据库中取得所有数据到productList中
然后request.setAttribute("product.list", productlist);
在jsp中<c:forEach items="${requestScope['product.list']}" var="products" varStatus="i">
<table width="64" border="0">
<table width="200" border="1">
<tr>
<td>
<div> <a
<img src="product/${products.photopath}"> </a>
</div>
</td>
</tr>
<tr>
<td>
<div>
<h5>
${products.product_name}
</h1>
</div>
</td>
</tr>
<tr>
<td>
<div>
<h5>
${products.product_price}金币
</h5>
</div>
</td>
</tr>
</table>
<c:if test="${((i.index + 1)%5) eq 0}"> <br> </c:if>
</c:forEach>