流读取硬盘图片展示到web页面
来源:互联网 发布:淘宝新势力周9月 编辑:程序博客网 时间:2024/06/03 03:58
页面:
<img src="${ctx}/img/readImg?prizeid=图片名字" />
后台:
只需要传入图片名称即可,
//prizeid 要下载的图片名字
public void readImg(String prizeid) {
FileInputStream fis= null;OutputStream out=null;
try {
out = response.getOutputStream();
//ResultStatic.path+prizeid+".jpg" 图片绝对地址
fis = new FileInputStream(new File(ResultStatic.path+prizeid+".jpg"));byte[] buffer = new byte[1024*8];
//读取文件流
int len = 0;
while ((len = fis.read(buffer)) != -1){
out.write(buffer,0,len);
}
out.flush();
} catch (Exception e) {
e.printStackTrace();
} finally {
if(fis != null){
try {
fis.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if(out != null){
try {
out.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
阅读全文
0 0
- 流读取硬盘图片展示到web页面
- 在jsp中通过I/O流方式读取图片并展示到页面
- 通过Servlet 将服务器硬盘图片 展示到浏览器
- 通过Servlet 将服务器硬盘图片 展示到浏览器
- 通过Servlet 将服务器硬盘图片 展示到浏览器
- java_通过Servlet 将服务器硬盘图片展示到浏览器
- php读取图片流输出到页面图片
- 数据库base64编码图片如何展示到页面上
- 将byte[] 数据输出到页面展示图片
- 【Web】从输入url到页面展示的过程
- 读取Excel中的十六进制转化为图片 存到硬盘
- 点击图片跳转到web页面
- 二维码及其图片页面展示
- jsp页面展示磁盘图片
- web页面流显示图片
- SpringMVC读取本地图片(byte[]流方式)显示到前端页面
- 图片存到数据库,并在页面读取出来
- 从数据库读取图片输出到页面中
- vueJs(2.x)+router+vuex简易博客系统<五>
- 基于Ethereum & IPFS的去中心化Ebay区块链项目开发实战
- ASP.NET Web Forms
- ASP.NET Web Forms
- 记录一段使用socket 回复的http json的请求代码
- 流读取硬盘图片展示到web页面
- Spark(Accumulator)陷阱及解决办法
- Could not autowire. No beans of 'UserMapper' type found.
- ASP.NET Web Forms
- pku3261 Milk Patterns 后缀数组/可重叠的 k 次最长重复子串
- 【第1119期】Git的4个阶段的撤销更改
- “智造”新机遇,制造业与边缘计算擦出智慧火花
- 超百场演讲总有一款适合你,GNTC约起来!
- java中怎样快速的读取文件