日期:2014-05-18 浏览次数:20721 次
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'
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+"'/>