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);
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);
相关文章推荐
- c#设计模式---建造者模式(Builder Pattern)
- [UGUI] Rect Transform
- StringBuilder用法
- mysql select column default value if is null
- Quick-Coco2d-x 打包 Android 与 环境搭建
- 关于UIView的Layer,IOS提供了三个方法
- checkbox未选中状态不传递value的解决办法
- UIAlertView和UIActionSheet
- C# NameValueCollection集合
- android-gradle-深入浅出-五:build type
- 《APUE》 第一章 图1-7 程序代码中execlp()部分解析
- ReportBuilder 中的参数设置
- 然而Android Custom UI
- 黑马程序员——Java基础--GUI
- 关于easyUI的datagrid的编辑功能时的问题
- CodeForces 3D Least Cost Bracket Sequence优先队列
- avalon中require的实现
- easyui-datagrid多笔删除的BUG
- 设计师也不能开口跪,看看你会不会谈客户!
- Android GUI系统学习1:Gralloc