jsp怎么实现这个效果哦~~~?

dd4ll 2008-01-09 03:21:30
在jsp中怎么实现 数据库读出来的记录在页面上分两列显示 如


1 忍忍忍 2 让让让
3 太太太 4 我我我
5 数数数 6 出出出
7 记记记 8 页页页
上页 下页

asp上 有个next 用个循环就可以了 java的logic:iterate 怎么弄呢~~~
高手们指点下哦
...全文
268 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
lindazch 2008-01-19
  • 打赏
  • 举报
回复
logic:iterate 循环<td>
dd4ll 2008-01-19
  • 打赏
  • 举报
回复
上去 上去 上去
Bob_ouyang 2008-01-19
  • 打赏
  • 举报
回复
在<table/>里面 用 <for:Each/> 循环 就可以达到.
<for:Each/>是jstl里面的标签.你得导入jstl
pigengler 2008-01-15
  • 打赏
  • 举报
回复
先用for循环实现以下你的效果,再说一下 logic:iterate 与for循环的类似之处;

<table>
<%for(int i=0;i<objs.length;i++){%>
<%if(i%2=0){out.print("<tr>");}%> //这里控制 两列才换一行;

<td><%=i%> <%=objs[i]%></td>

<%if(i%2=1){out.print("</tr>");}%> //这里控制 两列才换一行;
<%}%>
</table>

logic:iterate 与for循环 类似
<logic:iterate indexId="index" id="Item" name="objs" >
<%for(int i=0;i<objs.length;i++){%>

iterate 中的 index 相当于 for 中的 i
iterate 中的 Item 相当于 for 中的 objs[i]



hmilyld 2008-01-15
  • 打赏
  • 举报
回复
用<li>然后左浮动,嘎嘎.
dd4ll 2008-01-15
  • 打赏
  • 举报
回复
自顶一下
lanzhengwu 2008-01-10
  • 打赏
  • 举报
回复
条件判断下啊。。给个思路。。
if(i%2==0){
<tr>
}
<td>
</td>
if(i%2==1){
</tr>
}
dd4ll 2008-01-10
  • 打赏
  • 举报
回复
有没有好的方法啊
sun_IT 2008-01-09
  • 打赏
  • 举报
回复
顶起
什么都不能 2008-01-09
  • 打赏
  • 举报
回复
<style>
li{float:left;}
</style>
<div style="width:200px;">
<ul>
<%--loop--%>
<logic:iterator>
<li></li>
</logic:iterator>
</ul>
</div>
调整div的宽度,就可以调整一行显示的数量。
danier_sky 2008-01-09
  • 打赏
  • 举报
回复
可以参考下,用的是C标签
<table width="100%" >
<tr>
<td colspan="4"></td>
<c:forEach var="item" items="${query_list}" varStatus="status">
<c:if test="${status.index%2==0}">
</tr>
<tr id="tr_terminal${status.index/2}" class="biao-bg" style="display:">
</c:if>
<td width="25%" style="font-size:11px;display:;" valign="top" >
<DIV title="${item.param_code}" STYLE="width: 160px; overflow: hidden; text-overflow:ellipsis">
<NOBR>
<c:if test="${rssForm.rssInfo.cbx==1}">
<input type="checkbox" id="cb_${item.param_code}" name="cb_weather" ${item.bool==true?"checked":""} value="${item.param_code}">
</c:if>
<c:if test="${rssForm.rssInfo.cbx==0}">
<input type="checkbox" id="cb_${item.param_code}" name="cb_weather" disabled value="${item.param_code}">
</c:if>
[${item.param_code}]${item.param_name}
</NOBR>
</DIV>
</td>
<c:if test="${status.last}">
<c:forEach var="i" begin="${status.index+1}" end="${2-(status.index)%4+status.index-1}">
<td width="25%"> </td>
</c:forEach>
</c:if>
</c:forEach>
</tr></table>
dd4ll 2008-01-09
  • 打赏
  • 举报
回复
从数据库读出的记录是放在数组中的
dd4ll 2008-01-09
  • 打赏
  • 举报
回复
logic:iterate 一次读两条记录

81,116

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧