jsp结果集分列显示问题
我想分两列显示,或三列,那代码怎么写?
我的数据库中本来就有两列studentid,studentname,可是我在网页中想这样显示:学号 姓名 学号 姓名
studentid,studentname studentid,studentname 怎么样才能实现?不好意思打扰各位高手休息了,先去休息吧,明天再理我这个问题也行,多谢了!
我想分两列显示,或三列,那代码怎么写?
我的数据库中本来就有两列studentid,studentname,可是我在网页中想这样显示:学号 姓名 学号 姓名
studentid,studentname studentid,studentname 怎么样才能实现?不好意思打扰各位高手休息了,先去休息吧,明天再理我这个问题也行,多谢了!
<tr>
<th>学号</th>
<th>姓名</th>
<th>学号</th>
<th>姓名</th>
</tr>
<%
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:aaa");
Statement sta=con.createStatement();
ResultSet res=sta.executeQuery("select * from student");
while(res.next())
{
%>
<tr>
<td><%=res.getInt(1) %></td>
<td><%=res.getString(2) %></td>
<%if(res.next()){%>
<td><%=res.getInt(1) %></td>
<td><%=res.getString(2) %></td>
<%}else{
out.println("<td> </td>");
out.println("<td> </td>");
}%>
</tr>
<%
}
}
catch(Exception e)
{
out.println(e);
}
%>
</table>
else{
out.println("<td> </td>");
out.println("<td> </td>");
}
才没有出错,否则有问题,呵呵,总之多谢了