web图片上传和数据库取出Blob传到页面显示图片
来源:互联网 发布:淘宝牛排5大品牌 编辑:程序博客网 时间:2024/06/05 06:36
@RequestMapping(value="insertReagent",method=RequestMethod.POST) @ResponseBody public Integer insertReagent(@RequestParam("file")MultipartFile file,Reagent reagent){ try { byte[] logo=file.getBytes(); reagent.setImage_path(logo); } catch (IOException e) { e.printStackTrace(); } int i = reagentservice.insertReagent(reagent); return i; }
method=RequestMethod.POST仅支持post方式
@RequestParam(“file”)MultipartFile 限定名字叫file的参数传入封装成MultipartFile 对象
byte[] logo=file.getBytes();取出文件的字符数组
从数据库取出字符数组,输出到页面
@RequestMapping("reagentImage") public void reagentImage(String rea_id,HttpServletResponse resq) throws IOException{ Reagent reagent = reagentservice.queryReagentId(rea_id); resq.setContentType("image/jpg"); resq.getOutputStream().write(reagent.getImage_path()); }
setContentType这 个方法设置发送到客户端的响应的内容类型
resq.getOutputStream().write(reagent.getImage_path());
返回一个记录二进制的响应数据的输出流
<img id="image" alt="" src="/MedLab/reagentImage.do?rea_id=78">
页面img src直接指向方法
阅读全文
0 0
- web图片上传和数据库取出Blob传到页面显示图片
- 数据库存储BloB格式图片,并从数据库中取出显示到页面中
- 取出Oracle数据库中Blob类型的未编码图片流显示在JSP页面上
- struts2中使用Blob类型处理图片上传保存在数据库中并在JSP页面中显示图片
- J2EE使用hibernate存储和显示BLOB图片(从页面到数据库)
- 利用数据库如何存入BLOB格式图片,并从数据库中取出BLBO格式图片显示出来
- JSP页面直接显示Blob类型图片
- 如何在struts2的框架下显示从数据库中取出的图片?图片以Blob格式保存,取出后用怎样的标签呢?
- grails从数据库读取blob显示图片
- 图片文件上传(blob)
- 页面上传图片及时显示
- 图片上传和显示
- vue上传图片到数据库并显示到页面
- 取出数据库中BASE64编码后的图片二进制流数据显示在JSP页面上
- JSP读取Oracle数据库里的图片Blob字段并显示在页面上
- 当前页面需要显示上传的图片。图片并不需要上传到服务器存入数据库中
- sqlite3数据库存取和取出图片
- java读取图片插入blob,并取出
- Redis在Windows下的安装
- 【leetcode】7. Reverse Integer(Python & C++)
- C#之app.config、exe.config和vshost.exe.config作用区别
- 一元多项式的乘法与加法运算(20 分)
- 深入浅出理解分类(category)和类扩展(extension)
- web图片上传和数据库取出Blob传到页面显示图片
- Spring源码阅读-- 解析自定义命名空间的标签
- 【SpringBoot】Hello SpringBoot
- 神坑的水题
- 排序算法
- javax.crypto.BadPaddingException: Given final block not properly padded解决方案
- 搭建hadoop
- OpenCV Error: Assertion failed (dsize.area() > 0) in cv::resize
- Spring注解详解