把网站的所有图片全显示出来 在jsp中进行迭代 当type=10的时候把广告图片显示在网页上,可怎么在jsp中进行迭代呢
下面是我写的得代码
public class Adlist {
private Connection conn = null;
private PreparedStatement pst = null;
private ResultSet rs = null;
private BaseDBConnection db = new BaseDBConnection();
private String path = null;
public String getPath(int type){
String sql = "select path from adlist where type = "+type+" order by id desc ";
conn = db.getConn();
try { pst = conn.prepareStatement(sql);
rs = pst.executeQuery(); while(rs.next()){
path = rs.getString("path");
//path = rs.getString(1);
}
} catch (SQLException e) { e.printStackTrace();
}
return path;
}
}
下面是我写的得代码
public class Adlist {
private Connection conn = null;
private PreparedStatement pst = null;
private ResultSet rs = null;
private BaseDBConnection db = new BaseDBConnection();
private String path = null;
public String getPath(int type){
String sql = "select path from adlist where type = "+type+" order by id desc ";
conn = db.getConn();
try { pst = conn.prepareStatement(sql);
rs = pst.executeQuery(); while(rs.next()){
path = rs.getString("path");
//path = rs.getString(1);
}
} catch (SQLException e) { e.printStackTrace();
}
return path;
}
}
java.util.Vector v=pageCtl.getResult();//此处得到你方法的结果集就OK了
java.util.Enumeration e = v.elements();
while(e.hasMoreElements())
{
Object[] obj = (Object[])e.nextElement();
%>
<tr>
<td align="center" width="50%"><%=obj[0]%></td>
<td align="center" width="50%"><%=obj[1]%></td>
</tr>
<%} %>
我用JAVABEAN传的值