-1
我正在通过以下Servlet方法从mysql数据库检索图像字节:如何在jsp中显示图像
然后在jsp页面中显示图像字节。
请告诉我如何在我的jsp页面中使用img标签。
public byte[] getProfilePicture(int id) {
byte[] bytes = null;
try {
connection = dataSource.getConnection();
pst = connection.prepareStatement("SELECT profile_picture FROM users WHERE id = '"+id+"' ");
resultSet = pst.executeQuery();
while(resultSet.next()) {
bytes = resultSet.getBytes("profile_picture");
}
} catch(Exception e) {
e.printStackTrace();
}
return bytes;
}
谢谢,我等待着您的一种回应。