关于next()的使用方法。比如在WHILE中。 每执行一句 rs.()next语句,结果集的游表会向下移动一次,所以,你取的三个字段,分别是三条纪录的 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 据观察得出结论,由于你的第一个while循环已经把纪录的指针指到了最后,后面两个while当然取不到纪录了 hehe,()加错了 是rs.next()不好意思 while(rst.next()){ String Ctitle=new String(rst.getString("maintitle") String Cdate=new String(rst.getString("date")); String Cid=new String(rst.getString("id"));}这样就行了 正如楼上的朋友所说如果要是现你的功能可以先把所有的纪录都存放到一个Vector中vector的每个元素都是vector,里面存放表中行的内容这样就行了,要不你的resultSet每读一次,第二次读时把它的游标回到起始位置 xuyang821225(CSDN账号) while(rst.next()){ String Ctitle=new String(rst.getString("maintitle") String Cdate=new String(rst.getString("date")); String Cid=new String(rst.getString("id"));}意思是说,我的游标到了最下面吗?是不是这样就不能再回到头上进行再取值了呢?我换成上面的代码,后面还想动态生成<td></td>就直接在一个WHILE中做吗?我试了一次,还是不行。下面这一句有问题吗?<input type="text" name="<%=rst.getString("id")%>我不知道能不能这样用。 <td> <%try{ while(rst.next()) { String Ctitle=new String(rst.getString("maintitle")); String Cdate=new String(rst.getString("date")); String Cid=new String(rst.getString("id")); %> <%=Ctitle%><br> </td> <td> <%=rst.getString("date")%><br> </td> <td> <form method="post" action=" "> <input type="text" name="<%=rst.getString("id")%>" size="20"><input type="submit" value="提交" name="B1"><br> </form><%} %> </td>我把程序修改为上面的情况,还是同样的提示。是不是还有什么地方不合适呢? 又改了一次代码,还是不行。代码如下: <%try{ while(rst.next()) { String Ctitle=new String(rst.getString("maintitle")); String Cdate=new String(rst.getString("date")); String Cid=new String(rst.getString("id")); %> <td> <%=Ctitle%> </td> <td> <%=Cdate%> </td> <td> <form method="post" action=" "><input type="text" name="<%=Cid%>" size="20"><input type="submit" value="提交" name="B1"> <%} %></form></td> struts2--validator返回的message没有被覆盖 flex3中的.calculateHeight()在flash builder4中哪去了? 新手求助~帮帮忙啊~关于select下拉框级联的问题。 求一条SQL语句,有效马上给分 为什么在UseBean那儿报错? 关于JAVA接口中的疑问 JSP中音乐文件如何保存在MSSQLServer 推荐一个超强的在线图片批量上传控件!! 帮忙看看代码,一个关于JSP页面的调试错误! 谁能给我用jsp连接access的代码?马上给分! 有没有JSP的帮助文档(准确的说是HTML的帮助文档) xuyang821225来接分
不好意思
String Ctitle=new String(rst.getString("maintitle")
String Cdate=new String(rst.getString("date"));
String Cid=new String(rst.getString("id"));
}这样就行了
如果要是现你的功能可以先把
所有的纪录都存放到一个Vector中
vector的每个元素都是vector,里面存放表中行的内容
这样就行了,要不你的resultSet每读一次,第二次读时
把它的游标回到起始位置
while(rst.next()){
String Ctitle=new String(rst.getString("maintitle")
String Cdate=new String(rst.getString("date"));
String Cid=new String(rst.getString("id"));
}
意思是说,我的游标到了最下面吗?是不是这样就不能再回到头上进行再取值了呢?我换成上面的代码,后面还想动态生成<td></td>
就直接在一个WHILE中做吗?
我试了一次,还是不行。
下面这一句有问题吗?
<input type="text" name="<%=rst.getString("id")%>
我不知道能不能这样用。
while(rst.next())
{
String Ctitle=new String(rst.getString("maintitle"));
String Cdate=new String(rst.getString("date"));
String Cid=new String(rst.getString("id"));
%>
<%=Ctitle%><br>
</td>
<td> <%=rst.getString("date")%><br>
</td>
<td> <form method="post" action=" "> <input type="text" name="<%=rst.getString("id")%>" size="20"><input type="submit" value="提交" name="B1"><br>
</form><%}
%> </td>
我把程序修改为上面的情况,还是同样的提示。
是不是还有什么地方不合适呢?
<%try{
while(rst.next())
{
String Ctitle=new String(rst.getString("maintitle"));
String Cdate=new String(rst.getString("date"));
String Cid=new String(rst.getString("id"));
%>
<td> <%=Ctitle%>
</td>
<td>
<%=Cdate%>
</td>
<td> <form method="post" action=" "><input type="text" name="<%=Cid%>" size="20"><input type="submit" value="提交" name="B1">
<%}
%></form></td>