首页 > 代码库 > img显示从数据库取出blob字段
img显示从数据库取出blob字段
@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="http://www.mamicode.com/${ctx}/PersonPages/getPictureForpeople" style="width: 100px;height:120px;border:5px solid #104365;clear: both; display: block; margin:auto; "/>
img显示从数据库取出blob字段
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。