0
我想從mysql表中獲取多個圖像並將其顯示在桌面上。從mysql中獲取多個圖像並在桌面上顯示
我的代碼有什麼問題? 這裏是我的代碼
<%@ page import="java.sql.*"%>
<%@ page import="java.io.*"%>
<%
response.setContentType("image/gif");
OutputStream o = response.getOutputStream();
Blob image = null;
//long imgLen;
Connection con = null;
byte[ ] imgData = null ;
Statement stmt = null;
ResultSet rs = null;
try
{
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection("jdbc:mysql://localhost:3306/document","root","root");
stmt = con.createStatement();
rs = stmt.executeQuery("select * from document_upload");
%>
<html>
<body>
<table border=2>
<tr>
<td>img
</td>
<%
while(rs.next())
{
%>
<td>
<%
image = rs.getBlob(1);
imgData = image.getBytes(1,(int)image.length());
o.write(imgData);%></td></tr></table>
<%
}
o.close();
} catch (Exception e)
{
out.println("Unable To Display image");
out.println("Image Display Error=" + e.getMessage());
}
%>
我有它顯示了在一個時刻只能有一個形象問題。 我試圖在while循環中添加表標籤,但仍然存在問題。 的圖像被顯示在該是一個接一個像層..