主题:JSP前台页面的显示问题,高手帮帮忙。拜托了!!!!!
问题是这样的。我从后台数据库中取出记录集,然后在前台JSP页面中显示。希望以多行多列来显示。可是代码中却要把显示多行要么显示多列。。。。。
类如下:
//取出精品记录
public Collection JingPin(){
String str="select * from zqc.product where jingpin='1'";
linkoracle jd=new linkoracle();
Vector v=new Vector();
conn=jd.getConn();
stmt=jd.getStatement(conn);
try {
rs = stmt.executeQuery(str);
while(rs.next()){
product p=new product();
p.setBianHao(rs.getString("bianhao"));
p.setName(rs.getString("name"));
p.setImage(rs.getString("image"));
p.setPrice(rs.getString("price"));
p.setCaiLiao1(rs.getString("cailiao1"));
p.setCaiLiao2(rs.getString("cailiao2"));
p.setCaiLiao3(rs.getString("cailiao3"));
p.setCaiLiao4(rs.getString("cailiao4"));
p.setCaiLiao5(rs.getString("cailiao5"));
p.setCaiLiao6(rs.getString("cailiao6"));
p.setCaiLiao7(rs.getString("cailiao7"));
v.add(p);
}
} catch (SQLException ex) { }
return v;
}
前台显示部分如下:
<%product p=new product();
int j=0;
for(int i=0;i<2;i++){
Iterator coll=p.JingPin().iterator();
%>
<tr align="center" valign="top">
<%while(coll.hasNext()&&j<2){
product plist=(product)coll.next();
%>
<td width="192">
<table width="180" height="180" border="0">
<tr>
<td height="120" align="center" valign="top"><a href="/Product/ProductDetail.asp?ProductID=54"><img name="flower" src="flowers/<%=plist.getImage()%>" width="100" height="110" alt="" border="0"></a></td>
</tr>
<tr>
<td align="center" valign="middle"><A href="/Product/ProductDetail.asp?ProductID=54" class="style68"><%=plist.getName()%></A></td>
</tr>
<tr>
<td align="center" valign="middle"><span class="style69">¥<%=plist.getPrice()%></span></td>
</tr>
</table>
</td>
<%j++;}%>
</tr>
<%}%>
类如下:
//取出精品记录
public Collection JingPin(){
String str="select * from zqc.product where jingpin='1'";
linkoracle jd=new linkoracle();
Vector v=new Vector();
conn=jd.getConn();
stmt=jd.getStatement(conn);
try {
rs = stmt.executeQuery(str);
while(rs.next()){
product p=new product();
p.setBianHao(rs.getString("bianhao"));
p.setName(rs.getString("name"));
p.setImage(rs.getString("image"));
p.setPrice(rs.getString("price"));
p.setCaiLiao1(rs.getString("cailiao1"));
p.setCaiLiao2(rs.getString("cailiao2"));
p.setCaiLiao3(rs.getString("cailiao3"));
p.setCaiLiao4(rs.getString("cailiao4"));
p.setCaiLiao5(rs.getString("cailiao5"));
p.setCaiLiao6(rs.getString("cailiao6"));
p.setCaiLiao7(rs.getString("cailiao7"));
v.add(p);
}
} catch (SQLException ex) { }
return v;
}
前台显示部分如下:
<%product p=new product();
int j=0;
for(int i=0;i<2;i++){
Iterator coll=p.JingPin().iterator();
%>
<tr align="center" valign="top">
<%while(coll.hasNext()&&j<2){
product plist=(product)coll.next();
%>
<td width="192">
<table width="180" height="180" border="0">
<tr>
<td height="120" align="center" valign="top"><a href="/Product/ProductDetail.asp?ProductID=54"><img name="flower" src="flowers/<%=plist.getImage()%>" width="100" height="110" alt="" border="0"></a></td>
</tr>
<tr>
<td align="center" valign="middle"><A href="/Product/ProductDetail.asp?ProductID=54" class="style68"><%=plist.getName()%></A></td>
</tr>
<tr>
<td align="center" valign="middle"><span class="style69">¥<%=plist.getPrice()%></span></td>
</tr>
</table>
</td>
<%j++;}%>
</tr>
<%}%>