从工程外读取图片,并显示
来源:互联网 发布:英文网络用语缩写 编辑:程序博客网 时间:2024/05/18 20:08
前台:
<img id="editImg_'+(i+1)+'" alt="" src="xxxController_loadImage?imageid='+url+'" style="width:100px;height: 100px">
后台:
@RequestMapping({"/xxxController_loadImage"})
public void out(){
FileInputStream fileInputStream=null;
OutputStream outputStream=null;
String fileid = request.getParameter("imageid"); // 获取文件的文件名
File file =new File(ResourceBundle.getBundle("config").getString("deadbeat_dir")+fileid);
if(file.exists()){
try {
fileInputStream = new FileInputStream(file); //
int i=fileInputStream.available(); //得到文件大小
byte data[]=new byte[i];
fileInputStream.read(data);
response.setContentType("image/*"); //设置文件类型
outputStream=response.getOutputStream(); //输出文件
outputStream.write(data); //输出数据
} catch (IOException e) {
this.logger.error(e.toString(), e);
} finally{
try {//关闭
outputStream.flush();
outputStream.close();
fileInputStream.close();
} catch (IOException e) {
// TODO Auto-generated catch block
this.logger.error(e.toString(), e);
}
}
}
}
- 从工程外读取图片,并显示
- PowerBuilder从数据库读取并显示图片。
- Jsp从数据库读取并显示图片
- java读取web工程目录之外的图片并显示
- 从数据库中读取Blob对象图片并显示
- C#从数据库中读取二进制数据,并显示图片
- 从数据库中读取Blob对象图片并显示
- ADO 从ACCESS数据库读取图片并显示出来
- 从浏览器剪切板中读取图片并显示--for chrome
- Android从SD卡读取图片并显示
- 从指定的路径中读取图片,并显示出来
- 从数据库中读取Blob对象图片并显示
- 从MySQL中读取图片并基于VTK显示
- Java从数据库中读取Blob对象图片并显示
- AngularJS+Spring Boot如何从后台读取并显示图片
- MFC读取图片并显示
- matlab读取图片并显示
- 图片保存到数据库和从数据库读取图片并显示(C#)
- dpdk 定时器学习,例子剖析以及注意事项
- 文章标题
- Popupwindow弹出窗口
- simpleImageTool又一纯java的简单而功能强的专门图片水印、缩放库,给gif加水印也很简单
- Tree----- 257. Binary Tree Paths(二叉树从根节点开始的所有路径)
- 从工程外读取图片,并显示
- 异或运算的性质
- java接口和多态
- Codevs非难题汇总
- Ucloud 必读
- 解决php的session异步请求堵塞问题(采用xhprof性能分析)
- 【备战秋招Day 10】经典面试题37-40及在线编程题28-30答案
- 基于cef ceflient做二次开发在开发环境部署中遇到过的坑
- wireshark的使用