时间:2021-07-01 10:21:17 帮助过:23人阅读
@RequestMapping("/getPictureForpeople")
public void getPictureForpeople(HttpServletRequest request, HttpServletResponse response) throws IOException, SQLException {
Connection conn = null;
conn = GetJDBCConnection.getJDBCConnection();
Statement stmt = conn.createStatement();
String getPicSQL = "select header from lc0039999.idmidentityinfo where code = ‘houzt‘";
ResultSet rs = stmt.executeQuery(getPicSQL);
Blob img=null;
if(rs.next()) {
img = rs.getBlob("header");
}
long size=img.length();
byte[] bs=img.getBytes(1, (int)size);
// response.setContentType("image/jpeg");
ServletOutputStream outs=response.getOutputStream();
outs.write(bs);
outs.flush();
}
<img src="${ctx}/PersonPages/getPictureForpeople" style="width: 100px;height:120px;border:5px solid #104365;clear: both; display: block; margin:auto; "/>
img显示从数据库取出blob字段
标签:resultset rpe head put oid entity 20px dmi throws