Ueditor图片上传设置(1.4.3 JSP版本) - 解决图片不能显示问题

转载:http://blog.csdn.net/pip123456/article/details/38120489


最近研究了一下Ueditor,发现图片上传功能不能直接使用,需要修改一些东西,记下来以备参考。

1. 修改com.baidu.ueditor.hunter.FileManager类下的一个方法,修改如下:

源代码

private String getPath ( File file ) {
String path = file.getAbsolutePath();
return path.replace( this.rootPath, "/" );
}

修改为:

private String getPath ( File file ) {
   String path = file.getAbsolutePath();
   String str=path.replace(this.rootPath.replaceAll("\\/", "\\\\"), "\\" );
   return str;
}

(此处如果不修改,会导致“在线管理”下的图片不能显示)


2. 修改image.js文件,有两处的图片地址设置有问题,这里导致的问题是上传的图片在编辑器中不能显示图片。

(1):需要自定义一个方法,获取当前项目的地址(方法比较笨,可自行修改)

function getRootPath(){
        //获取当前网址,如: http://localhost:8083/uimcardprj/share/meun.jsp
        var curWwwPath=window.document.location.href;
        var pathName=window.document.location.pathname;
        var pos=curWwwPath.indexOf(pathName);
        var localhostPaht=curWwwPath.substring(0,pos);
        var projectName=pathName.substring(0,pathName.substr(1).indexOf('/')+1);
        return localhostPaht + projectName;
    }

(2)分别在以下两个地方添加刚才获取的项目地址

约775行:

src: getRootPath() + prefix + data.url,
_src: getRootPath() + prefix + data.url,


约912行

img.setAttribute('src', getRootPath() + urlPrefix + list[i].url + (list[i].url.indexOf('?') == -1 ? '?noCache=':'&noCache=') + (+new Date()).toString(36) );
 img.setAttribute('_src', getRootPath() + urlPrefix + list[i].url);

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值