用servlet。主要代码如下:
ResultSet rs = pstmt.executeQuery();
if (rr.next()){
javax.servlet.ServletOutputStream outStream = response.getOutputStream();
java.io.ByteArrayOutputStream baos = new java.io.ByteArrayOutputStream();
int img_length = rr.getInt(1);
if (img_length > 0){
java.io.InputStream instream = rs.getBinaryStream(?);
byte b[] = new byte[1024];
while (true){
int bytes = instream.read(b);
if (bytes == -1)break;
baos.write(b, 0, bytes);
}
b = baos.toByteArray();
response.setContentLength(b.length);
outStream.write(b, 0, b.length);
}
ResultSet rs = pstmt.executeQuery();
if (rr.next()){
javax.servlet.ServletOutputStream outStream = response.getOutputStream();
java.io.ByteArrayOutputStream baos = new java.io.ByteArrayOutputStream();
int img_length = rr.getInt(1);
if (img_length > 0){
java.io.InputStream instream = rs.getBinaryStream(?);
byte b[] = new byte[1024];
while (true){
int bytes = instream.read(b);
if (bytes == -1)break;
baos.write(b, 0, bytes);
}
b = baos.toByteArray();
response.setContentLength(b.length);
outStream.write(b, 0, b.length);
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货