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循环中添加表标签,但仍然存在问题。 的图像被显示在该是一个接一个像层..