写了一个方法,用最简单的方式在页面中显示两行两列的图片。自认为是最简单的一种,在这里给献丑了。
public String viewImages() {
DBControl cnn = new DBControl();
StringBuffer strsql = new StringBuffer();
int rowCount = 2;
int columnCount = 2;
try {
String sqlstring = "select pic_url from imagepic";
String sqllist = "select * from (" + sqlstring + ") where rownum <=" + (rowCount * columnCount);
RowSet rss = cnn.rsRowset(sqllist);
if (rss.next()) {
for (int i = 1; i <= 2; i++) {
strsql.append("
");for (int j = 1; j <= 2; j++) {
if (rss.isAfterLast()) {
strsql.append("
");} else {
strsql.append("
");strsql .append("");
strsql.append("
");rss.next();
}
}
strsql.append("
");}
}
rss.close();
} catch (Exception e) {
}
return strsql.toString();
}
posted on 2006-06-08 09:06 fish的Blog 阅读(1386) 评论(0) 编辑 收藏 所属分类: Jsp