2 在数据库有blob格式可以存放图片 以二进制流的方式取出来
<% String zjbm = CheckParam(request.getParameter("zjbm"),"") String zpSql = "select zp from tjjryxxx where sfzh = '"+zjbm+"'" out.clear() response.setContentType("image/jpeg") response.setHeader("Content-Transfer-Encoding","base64") Connection connection = null PreparedStatement ps = null ResultSet rs = null Blob blob =null byte[] data = null try{ connection =getConn() ps = connection.prepareStatement(zpSql) rs = ps.executeQuery() while(rs.next()){blob = (Blob)rs.getBlob("zp") long nlen = blob.length() int nsize = (int) nlen data = blob.getBytes(1,nsize) OutputStream out1 = response.getOutputStream() BufferedOutputStream bos =null bos = new BufferedOutputStream(out1) bos.write(data,0,data.length) bos.close() rs.close() } }catch(Exception e){ e.printStackTrace()} %>
如果你想通过名称获取某个值,且名称和值之间是映射关系,你应该使用Map这一数据结构。Map<String, Integer>map = new HashMap<>()
map.put("a", 0)
map.put("b", 2)
map.put("c", 10)
System.out.println(map.get("b"))
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)