ueditor 添加支持文件存储到文件服务器
来源:互联网 发布:韩国语常用语网络 编辑:程序博客网 时间:2024/06/08 13:21
1、环境
ueditor.jar版本 为1.1.2
2、场景
1、在webapp开发中,需要将富文本中的文件存储到单独的文件服务器,而ueditor默认只能在web项目根路径下。
2、ueditor生成的富文本里图片路径是相对路径,因而在app端无法显示
3、快速解决方法
4、解决步骤
1、从官网下载jsp版本和完整源码 http://ueditor.baidu.com/website/download.html
2、按官方文档将jsp项目导入到eclipse或iead中并正常运行 http://fex.baidu.com/ueditor/#server-deploy
3、复制源码目录中\jsp\src\到iead项目源码中、并把ueditor-xxx.jar依赖去掉
此时的项目结构:
4、ueditor-xxx.jar的源码就不解析了。代码不多。大家大致看下就能懂了。
5、修改方法com.baidu.ueditor.ConfigManager.getConfig(int type);
在最加入
conf.put(“externalStoragePath”, this.jsonConfig.optString(“externalStoragePath”));
如下
6、在
com.baidu.ueditor.upload.BinaryUploader类中,添加如下方法取文件存储位置
private static String getPhysicalPath(Map<String, Object> conf, String savePath, String rootPath) { String externalStoragePath = (String) conf.get("externalStoragePath"); String physicalPath; if (externalStoragePath != null && externalStoragePath.trim().length() != 0) { physicalPath = externalStoragePath; } else { physicalPath = rootPath; } physicalPath += savePath; return physicalPath; }
将该类save(HttpServletRequest request,Map<String, Object> conf)方法中的 String physicalPath = rootPath + savePath;改成 String physicalPath = getPhysicalPath(conf, savePath, rootPath);
7、将com.baidu.ueditor.upload.Base64Uploader类按上述修改方式进行同样的修改。
8、大功告成
9、在ueditor/jsp/config配置中添加
"externalStoragePath":"/opt/fileService/img/",/*文件服务器路径*/"imageUrlPrefix": "http://xxx.xxx.xxx:8080/xxx/xxx", /* 图片访问路径前缀-要文件服务器的外网地址 */
3 0
- ueditor 添加支持文件存储到文件服务器
- ueditor 添加支持文件存储到文件服务器
- symbian文件服务器:文件存储
- UEditor保存图片时直接通过FTP上传到文件服务器
- post文件到FTP文件服务器
- H2内存数据库 支持存储到文件
- H2内存数据库支持存储到文件
- H2内存数据库 支持存储到文件
- 上传图片文件到Ueditor
- 百度富文本编辑器ueditor上传文件到对象存储BOS中
- 【Maven】添加ueditor到maven本地仓库
- 【Maven】添加ueditor到maven本地仓库
- ueditor 上传文件到ftp java
- 用WebClient将客户端上传文件保存到远端文件服务器
- HttpClient使用详解 (如何上传文件到文件服务器)
- 文件服务器之三:存储
- 文件服务器和流存储
- 百度UEditor添加视频 增加支持“通用代码”功能,支持微信
- ASO优化之教你如何得到ASO优化100关键词字符
- 自定义view——Path之基本操作(转载)-8
- Go语言小知识之map遍历
- SpringMVC集成Spring-Session进行分布式管理
- 线性代数笔记-2-矩阵消元
- ueditor 添加支持文件存储到文件服务器
- C#中的invoke方法
- JAVA FileOutputStream写文件覆盖问题
- SSM框架——详细整合教程(Spring+SpringMVC+MyBatis)
- 项目经理成长日记(一)——谈谈项目管理
- java中map的排序问题
- js中的"=="和equals()以及is()三者的区别
- SYN攻击检测与预防
- 路由基础(二)静态路由