我正在处理来自jsp的多表单页面。我必须以表格格式显示复选框,其值为value = id,它来自ArrayList对象中的ResultSet。所以我的问题是如何在value = id中显示每行设置的复选框。而row(记录)来自ArrayList。
我的JSP中的代码是:
<center>
<div style="margin:20px 0px 0px 0px; width:1100px; height:450px; background-color:lightgray" class="divBorder ">
<font color="#3B5998"><h3>Work Description</h3>
<table style="margin:20px 20px 20px 20px; border:solid 2px darkGray; border-spacing:5px " border="1"></font>
<tr><th width="20px">Select</th><th width="60px">Work Code</th>
<th width="700px">Description</th><th width="60px">Edit</th></tr>
<%
Work_Manager wm=new Work_Manager();
ArrayList<ArrayList<Object>> worklist=new ArrayList<ArrayList<Object>>();
ArrayList<Object> list = new ArrayList<Object>();
worklist=wm.getWork();
Iterator<ArrayList<Object>> it = worklist.iterator();
while(it.hasNext()){%>
<tr>
<%
list=it.next();
Iterator<Object> itr = list.iterator();
while(itr.hasNext()){%>
<td>
<%=itr.next()%></td>
<% }%>
<td><a href="#">Edit</a></td></tr>
<%
}
%>
</table>
<table style="margin:20px 20px 20px 20px;">
<tr><td><input class="btn" type="submit" value="Delete Selected List" onclick="" /></td></tr>
</table>
</div>
</center>
答案 0 :(得分:0)
从ResultSet
检索ArrayList
对象。
Resultset rs = (Resultset) iter.next();
while(rs.next()){
String value = rs.getString("your column name for id");
%>
<tr>
<td><input type = "checkbox" name="abc" value="<%=value%>">
<td>....</td>
</tr>
<%
}
%>
在创建表时动态传递此value
。