我不能顯示BLOB
圖像,我在保存mysql
。我有豆,jsp。我使用3層架構,我想用圖片顯示所有產品。顯示圖像存儲爲BLOB在數據庫
在acceesor:
try {
Connection cn = getVla().getConnection();
String sql = "SELECT * FROM products";
PreparedStatement pst = cn.prepareStatement(sql);
ResultSet rs = pst.executeQuery();
ArrayList<products> ls = new ArrayList<products>();
while(rs.next()) {
products s = new products();
s.setPk(rs.getLong("pk"));
s.setName(rs.getString("name"));
s.setPrice(rs.getDouble("price"));
s.setPic(rs.getBlob("pic"));
s.setComments(rs.getString("comments"));
ls.add(s);
}
return ls;
}
產品有:
public Blob getPic() {
return pic;
}
在main.jsp中
<%=
List<products> product = bean.getproducts();
%>
<h1>Product: </h1>
<%
for(products c : product) {
%>
From <%= c.getName()%> <br/>
<%= c.getPic()%></b><br/>
<b><%= c.getPrice()%> </b><br/>
<%= c.getComments()%>
<hr/>
<%
}
%>
我怎樣才能DIS播放圖片? (目前我正在顯示[email protected])
只是爲了澄清,你想要顯示**每個產品**圖片? – mthmulders 2013-04-05 13:32:13