写了一个方法,用最简单的方式在页面中显示两行两列的图片。自认为是最简单的一种,在这里给献丑了。
		          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("<tr>"); 
		                         for (int j = 1; j <= 2; j++) { 
		                           if (rss.isAfterLast()) { 
		                               strsql.append("<td></td>"); 
		                           } else { 
		                            strsql.append("<td>");
      
                           strsql .append("<img src='../..").append(rss.getString("pic_url")) .append( " 'width='80' height='60' border='0' />");
             
                           strsql.append("</td>");
                 
                           rss.next();
                          }
                     } 
		                  strsql.append("</tr>"); 
		               }
        } 
		            rss.close(); 
		
				
        } catch (Exception e) {
        }
		       return strsql.toString();
 } 
	posted on 2006-06-08 09:06 
fish的Blog 阅读(1892) 
评论(0)  编辑  收藏  所属分类: 
Jsp