怎么遍历一个list,根据list的自定义属性找到放置在table中的位置

J2EE 码拜 9年前 (2015-04-18) 1379次浏览 0个评论

我做的一个课程表
学生属性:

private String stuId;
	private String stuPass;
	private String stuName;
	private String stuGender;
	private String academy;
	private String stuClass;
	private ArrayList<Course> courses;

课程属性:

private String courseId;
	private float coursePoint;
	private String courseName;
	private String academy;
	private String index;
	private String courseTea;
	private String courseRoom;

页面显示:
<table width=”100%” border=”1″ cellpadding=”0″ cellspacing=”0″>
<tr>
<th width=”10%”></th>
<th>星期一</th>
<th>星期二</th>
<th>星期三</th>
<th>星期四</th>
<th>星期五</th>
</tr>
<tr height=”80″>
<th>一二节</th>
<td id=”1″></td>
<td id=”2″></td>
<td id=”3″></td>
<td id=”4″></td>
<td id=”5″></td>
</tr>
<tr height=”80″>
<th>三四节</th>
<td id=”6″></td>
<td id=”7″></td>
<td id=”8″></td>
<td id=”9″></td>
<td id=”10″></td>
</tr>
<tr height=”80″>
<th>五六节</th>
<td id=”11″></td>
<td id=”12″></td>
<td id=”13″></td>
<td id=”14″></td>
<td id=”15″></td>
</tr>
<tr height=”80″>
<th>七八节</th>
<td id=”16″></td>
<td id=”17″></td>
<td id=”18″></td>
<td id=”19″></td>
<td id=”20″></td>
</tr>
<tr height=”80″>
<th>九十节</th>
<td id=”21″></td>
<td id=”22″></td>
<td id=”23″></td>
<td id=”24″></td>
<td id=”25″></td>
</tr>
<tr height=”80″>
<th>十一十二节</th>
<td id=”26″></td>
<td id=”27″></td>
<td id=”28″></td>
<td id=”29″></td>
<td id=”30″></td>
</tr>
</table>
我想通过课程的index属性(1-30),然后和td的id相匹配,找到匹配到后把课程的信息在相应的地方显示出来。求大神们给个思路

怎么遍历一个list,根据list的自定义属性找到放置在table中的位置
一排一排的输出到对应的位置就行了,哪这么麻烦。
怎么遍历一个list,根据list的自定义属性找到放置在table中的位置
引用 2 楼 u013277115 的回复:

一排一排的输出到对应的位置就行了,哪这么麻烦。

怎么一排一排输出,不是每个位置都有数据

怎么遍历一个list,根据list的自定义属性找到放置在table中的位置
引用 1 楼 java_haopeng 的回复:

怎么遍历一个list,根据list的自定义属性找到放置在table中的位置

不懂啊- -。。

怎么遍历一个list,根据list的自定义属性找到放置在table中的位置
这还不简单 就像分奇偶数显示一样 用js细吧 这样逻辑代码好写
怎么遍历一个list,根据list的自定义属性找到放置在table中的位置
求大神写个代码看看,只说思路,小白我转不过弯啊
怎么遍历一个list,根据list的自定义属性找到放置在table中的位置
50分
你如果连一楼的代码都看不懂······那真的不是我们三两句能给你解释的清的了····随手给你贴一段很早的一个页面的布局,你看下你能看懂多少吧  从一页中间截的 肯定有找不到的变量 大概看下是那么个意思 你借鉴一下
<table width=”100%” border=”0″ cellspacing=”0″ cellpadding=”0″>
      <tr>
        <td width=”8″ background=”<%=basePath %>images/tab_12.gif”>&nbsp;</td>
        <td><table width=”100%” border=”0″ cellpadding=”0″ cellspacing=”1″ bgcolor=”b5d6e6″ onmouseover=”changeto()”  onmouseout=”changeback()”>
          <tr>
          <!– 
            <td width=”3%” height=”22″ background=”<%=basePath %>images/bg.gif” bgcolor=”#FFFFFF”><div align=”center”>
              <input type=”checkbox” name=”checkall” onclick=”checkAll();” />
            </div></td> –>
            <td width=”3%” height=”22″ background=”<%=basePath %>images/bg.gif” bgcolor=”#FFFFFF”><div align=”center”><span class=”STYLE1″>序号</span></div></td>
            <td width=”10%” height=”22″ background=”<%=basePath %>images/bg.gif” bgcolor=”#FFFFFF”><div align=”center”><span class=”STYLE1″>条形码</span></div></td>
            <td width=”10%” height=”22″ background=”<%=basePath %>images/bg.gif” bgcolor=”#FFFFFF”><div align=”center”><span class=”STYLE1″>设备名称</span></div></td>
            <td width=”15%” height=”22″ background=”<%=basePath %>images/bg.gif” bgcolor=”#FFFFFF”><div align=”center”><span class=”STYLE1″>设备类别</span></div></td>
            <td width=”10%” height=”22″ background=”<%=basePath %>images/bg.gif” bgcolor=”#FFFFFF”><div align=”center”><span class=”STYLE1″>品牌</span></div></td>
            <td width=”10%” height=”22″ background=”<%=basePath %>images/bg.gif” bgcolor=”#FFFFFF”><div align=”center”><span class=”STYLE1″>型号</span></div></td>
            <td width=”10%” height=”22″ background=”<%=basePath %>images/bg.gif” bgcolor=”#FFFFFF”><div align=”center”><span class=”STYLE1″>颜色</span></div></td>
            <td width=”10%” height=”22″ background=”<%=basePath %>images/bg.gif” bgcolor=”#FFFFFF”><div align=”center”><span class=”STYLE1″>容量</span></div></td>
            <td width=”10%” height=”22″ background=”<%=basePath %>images/bg.gif” bgcolor=”#FFFFFF”><div align=”center”><span class=”STYLE1″>固定资产编号</span></div></td>
             <td width=”10%” height=”22″ background=”<%=basePath %>images/bg.gif” bgcolor=”#FFFFFF”><div align=”center”><span class=”STYLE1″>设备状态</span></div></td>
           
            <td width=”10%” height=”22″ background=”<%=basePath %>images/bg.gif” bgcolor=”#FFFFFF” class=”STYLE1″><div align=”center”>基本操作</div></td>
          </tr>
          
           <%
             
            /*计算起始序号*/
             int startIndex = (currentPage -1) * 3;
             /*遍历记录*/
             for(int i=0;i<deviceList.size();i++) {
             int currentIndex = startIndex + i + 1; //当前记录的序号
             device device = deviceList.get(i); //获取到设备对象 
             %>
          <tr>
            <td height=”20″ bgcolor=”#FFFFFF”><div align=”center” class=”STYLE1″>
              <div align=”center”><%=currentIndex %></div>
            </div></td>
            <td height=”20″ bgcolor=”#FFFFFF”><div align=”center”><span class=”STYLE1″><%=device.getCode() %></span></div></td>
             <td height=”20″ bgcolor=”#FFFFFF”><div align=”center”><span class=”STYLE1″><%=device.getName() %> </span></div></td>
         <%int id=Integer.parseInt(device.getType().toString()); devicetypedao dvtdao=new devicetypedao(); devicetype dt= dvtdao.GetDeviceTypeById(id); %>
            <td bgcolor=”#FFFFFF”><div align=”center”><span class=”STYLE1″><%=dt.getDevicetypename() %></span></div></td>
            <td height=”20″ bgcolor=”#FFFFFF”><div align=”center”><span class=”STYLE1″><%=device.getBrand() %></span></div></td>
             <td height=”20″ bgcolor=”#FFFFFF”><div align=”center”><span class=”STYLE1″><%=device.getModel() %></span></div></td>
            <td height=”20″ bgcolor=”#FFFFFF”><div align=”center”><span class=”STYLE1″><%=device.getColor() %></span></div></td>
            <td height=”20″ bgcolor=”#FFFFFF”><div align=”center”><span class=”STYLE1″><%=device.getCapacity() %></span></div></td>
            <td height=”20″ bgcolor=”#FFFFFF”><div align=”center”><span class=”STYLE1″><%=device.getPropertynumber() %></span></div></td> 
            <td height=”20″ bgcolor=”#FFFFFF”><div align=”center”><span class=”STYLE1″><%=device.getStatus() %></span></div></td>
            
            
            <td height=”20″ bgcolor=”#FFFFFF”><div align=”center”>
            <span class=”STYLE4″>
            <span style=”cursor:pointer” onclick=”location.href=””<%=basePath %>/device/devicemodifyquery.action?code=<%=device.getCode() %>”””><img src=”<%=basePath %>images/edt.gif” width=”16″ height=”16″/>编辑&nbsp; &nbsp;</span>
            <img src=”<%=basePath %>images/del.gif”  style=”cursor:pointer” width=”16″ height=”16″/><a href=”<%=basePath  %>/device/devicedelete.action?code=<%=device.getCode() %>” onclick=”return confirm(“”确定删除本设备吗?””);”>删除</a></span>
            </div></td>
          </tr>
          <% } %>
          
        </table></td>
        <td width=”8″ background=”images/tab_15.gif”>&nbsp;</td>
      </tr>
    </table>
            
       效果是怎么遍历一个list,根据list的自定义属性找到放置在table中的位置

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明怎么遍历一个list,根据list的自定义属性找到放置在table中的位置
喜欢 (0)
[1034331897@qq.com]
分享 (0)

文章评论已关闭!