您的位置:首页 > 产品设计 > UI/UE

Ueditor图片上传设置(1.4.3 JSP版本)

2015-07-10 13:14 701 查看
最近研究了一下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);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: