当前位置: 代码迷 >> Java Web开发 >> Extjs DataView 图片显示不出 进来就有分 呀 多谢大家了
  详细解决方案

Extjs DataView 图片显示不出 进来就有分 呀 多谢大家了

热度:829   发布时间:2016-04-17 17:22:29.0
Extjs DataView 图片显示不出 进来就有分 呀 谢谢大家了
JScript code
var imageList = new Ext.data.Store({        autoLoad:true,        reader:new Ext.data.JsonReader({            totalProperty:'results',            root:'items',            fields:[                 'picName','picUrl'                ]        }),        proxy:new Ext.data.HttpProxy({            url:"findImg_findPic.action"        })    })        var tpl = new Ext.XTemplate(    '<tpl for=".">',        '<div class="thumb-wrap" id="{picName}">',        '<div class="thumb"><img src="{picUrl}" title="{picName}"></div>',           '</tpl>',    '<div class="x-clear"></div>'    );panel=========================items:[new Ext.DataView({        store: imageList,       tpl: tpl,       autoHeight:true,       multiSelect: true,             overClass:'x-view-over',       itemSelector:'div.thumb-wrap',        emptyText: 'No images to display'


------解决方案--------------------
草的 整个csdn 墨迹死了这个问题 我日了
------解决方案--------------------
现在都到4.0了呵呵最起码也得用个3.0啊.
------解决方案--------------------
我靠,这个lz人呢,难道gaoshanwlm你就是lz。


关键是看你的json咋拼的

WebRoot-->upload

http://xxx.xx.xx/Extjs_Hello3.2/upload/1315992845704.JPG试试。
这个url不就是么?红色部分这样获得

Java code
   String path = request.getContextPath();   String basePath = request.getScheme() + "://"      + request.getServerName() + ":" + request.getServerPort()      + path + "/";
------解决方案--------------------
显示图片我一般是直接再写个action来处理,直接用img标签显示会有这个问题的
action写法
public String showImage() throws Exception {
// 根据图片地址构造file对象
File file = new File(imageUrl);
InputStream is = new FileInputStream(file);
Image image = ImageIO.read(is);// 读图片
String imageType = imageUrl.substring(imageUrl.lastIndexOf(".") + 1);
RenderedImage img = (RenderedImage) image;
OutputStream out = response.getOutputStream();
ImageIO.write(img, imageType, out);
out.flush();
out.close();
return null;
}

jsp页面
src='showImage.action?imageUrl="+imgUrl+"'/>
  相关解决方案