说起来 实现百度富文本编辑器也是比较简单,主要就是 读取 config.json

但是里面的坑也比较大   下面是我的步骤 以及我遇坑的过程

  • 准备引入的jar包 这两个包找不到的话 可以去官网、也可以加群Java交流群,在群文件自行下载:  QQ群:808249297
<!--用于ueditor--><dependency><groupId>com.cns.diy-ueditor</groupId><artifactId>json</artifactId><version>1.0</version></dependency><!--用于ueditor--><dependency><groupId>com.cns.diy-ueditor</groupId><artifactId>ueditor</artifactId><version>1.1.2</version></dependency>
  • 将静态资源复制到资源下面

随后重要的来了! 将config.json  粘贴到 resources下面

这里如果不粘到这个下面 后面写的controller会读取不到  会报错

  • 页面上引入js
<script th:src="@{/ueditor/ueditor.config.js}"></script>
<script th:src="@{/ueditor/ueditor.all.js}"></script>

html里面


<textarea style="width: 100%;height: 280px;" type="text" id="learnContent" name="learnContent" ></textarea>

js里面

var ue = UE.getEditor('learnContent', {zIndex: "0",toolbars: [['fullscreen', 'undo', 'redo', '|','bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'superscript', 'subscript', 'removeformat', 'formatmatch', 'autotypeset', 'blockquote', 'pasteplain', '|', 'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist', 'selectall', 'cleardoc', '|','rowspacingtop', 'rowspacingbottom', 'lineheight', '|','customstyle', 'paragraph', 'fontfamily', 'fontsize', '|','directionalityltr', 'directionalityrtl', 'indent', '|','justifyleft', 'justifycenter', 'justifyright', 'justifyjustify', '|','link', 'unlink', '|', 'imagenone', 'imageleft', 'imageright', 'imagecenter', '|','simpleupload', 'insertimage', 'attachment','map', '|','horizontal', 'spechars', '|','inserttable', 'deletetable', 'insertparagraphbeforetable', 'insertrow', 'deleterow', 'insertcol','deletecol', 'mergecells', 'mergeright','mergedown', 'splittocells', 'splittorows', 'splittocols', '|', 'preview', 'searchreplace']]});UE.Editor.prototype._bkGetActionUrl = UE.Editor.prototype.getActionUrl;UE.Editor.prototype.getActionUrl = function (action) {if (action == 'uploadimage' || action == 'uploadscrawl' || action == 'uploadvideo') {return '/upload/uploadUEditorImage?pid=' + '[[${id}]]';} else if (action == 'uploadfile') {return '/upload/uploadUEditorFile?pid=' + '[[${id}]]';} else {return this._bkGetActionUrl.call(this, action);}}

要注意的是  要注意的是 要注意的是

这里一定要打空格  否则 报错!!!

下面两个是 视频 或者图片 文件的上传接口  可以把文件跟图片写在一个接口里面 后台拿到去判断该走那个方法就行了

controller里面写

@Controller
@RequestMapping("/ueditor")
public class UeditorController {
@RequestMapping("/getJsonController")
@ResponseBody
public void getConfigInfo(HttpServletRequest request, HttpServletResponse
response) {
org.springframework.core.io.Resource res = new
ClassPathResource("config.json");
InputStream is = null;
response.setHeader("Content-Type", "text/html");
try {
is = new FileInputStream(res.getFile());
StringBuffer sb = new StringBuffer();
byte[] b = new byte[1024];
int length = 0;
while (-1 != (length = is.read(b))) {
sb.append(new String(b, 0, length, "utf-8"));
}
String result = sb.toString().replaceAll("/\\*(.|[\\r\\n])*?\\*/",
"");
JSONObject json = JSON.parseObject(result);
PrintWriter out = response.getWriter();
out.print(json.toString());
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
is.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}

在这里面修改 成controller的路径

现在就大功告成了

java前沿技术交流群:808249297

Java实现百度富文本编辑器UEditor相关推荐

  1. 百度富文本编辑器UEditor安装配置全过程

    网站开发时富文本编辑器是必不可少的,他可以让用户自行编辑内容的样式然后上传到后台!下面我们来介绍如何安装使用百度富文本编辑器 一.下载并且设置百度富文本编辑器的样式     你可以去百度UEditor ...

  2. 百度富文本编辑器ueditor在https协议下无法正常插入动态地图

    在浏览器https协议下,百度富文本编辑器ueditor有可能会无法正常插入动态地图.所谓"动态地图",就是在插入地图的时候,勾选右上角的"动态地图"选择框: ...

  3. 百度富文本编辑器ueditor支持上传mp3格式等音频文件的方法

    百度富文本编辑器ueditor算得上比较强大的了,但是有一个比较令人难受的问题,就是不支持本地上传音频文件.ueditor自带的mp3功能是直接在百度音乐里面搜索加进去的,显而易见这个不是我们想要的, ...

  4. TP5.1框架中百度富文本编辑器UEditor的使用

    在实际项目开发中最常使用到的工具之一就是富文本编辑器,使用富文本编辑器可以实现所见即所得的效果,且所有富文本编辑器里的内容(包括图片,视频,音乐等文件)全部可以带格式的存入数据库中且只需占用一个字段. ...

  5. Html引入百度富文本编辑器ueditor

    在日常工作用,肯定有用到富文本编辑器的时候,富文本编辑器功能强大使用方便,我用的是百度富文本编辑器,首先需要下载好百度编辑器的demo, 然后创建ueditor.html文件,引入百度编辑器,然后在h ...

  6. themyleaf 图片上传_springboot thymeleaf 整合 百度富文本编辑器UEditor进行图片上传

    项目中需要使用到富文本编辑器,找来找去发现百度UEditor富文本编辑器在国内最为常用因此就尝试引入.编辑器官网是:http://ueditor.baidu.com/website/index.htm ...

  7. html页面引入富文本编辑器,Html引入百度富文本编辑器ueditor

    在日常工作用,肯定有用到富文本编辑器的时候,富文本编辑器功能强大使用方便,我用的是百度富文本编辑器,首先需要下载好百度编辑器的demo, 然后创建ueditor.html文件,引入百度编辑器,然后在h ...

  8. Vue 百度富文本编辑器Ueditor Spring Boot 前后台整合示例(附带完整源码)

    前端 安装vue-ueditor-wrap npm i vue-ueditor-wrap 引入并注册VueUeditorWrap组件,配置组件属性 <script> import VueU ...

  9. 百度富文本编辑器ueditor插入html代码

    记录工作中遇到的问题 需求:  文本编辑器左侧展示模板,点击左侧模板将模板展示到富文本编辑器内. 代码: // 点击模板时添加到编辑器内 $(".templates-con ul li&qu ...

  10. 百度富文本编辑器UEditor 图片宽度100%自适应,手机端

    有些时候富文本编辑器的图片在手机端显示超出,没有自动100% 修改ueditor.all.js的23774行(左右,不一定)和24533(左右,不一定),不行就搜索 增加内容 loader.setAt ...

最新文章

  1. 基于VTK的Delaunay的三角剖分算法
  2. Android 开发应该掌握的 Proguard 技巧
  3. c语言 字符串数组末尾,C语言中,利用宏定义一个字符串和字符数组定义的字符串其末尾都会自动添加\0字符...
  4. VTK:图片之ImageRotate
  5. C语言循环求出2的10次幂,C语言求2的100次幂的结果.doc
  6. 光耀卡服务器维修,3月28日服务器更新维护公告
  7. mysql 按照条件计数_灵活的CASE...WHEN:SQL同时按条件计数按条件加和
  8. 2021年Q2小米手机销量超苹果跻身全球第二 雷军:新的里程碑
  9. 【Elasticsearch】 es 搜索 返回信息 字段 解释
  10. cad转dxf格式文件太大_如何玩转CAD看图?1分钟,一款完全免费的高效软件,解决所有看图...
  11. 编程之美2.17 数组循环移位
  12. 一起看2018阿里技术参考图册(算法篇)
  13. 阶段3 2.Spring_03.Spring的 IOC 和 DI_5 BeanFactory和ApplicationContext的区别
  14. JS:如何正确绘制文字
  15. Java语言实现word转PDF(10分钟解决)
  16. Windows 和 Linux 的免费媒体播放器 - SMPlayer
  17. Web前端-HTML学习笔记一
  18. 阿里云ECS vpc网络与办公网内网互通
  19. 2021年真无线蓝牙耳机排名:人气排名前十的蓝牙耳机推荐
  20. 怎么在matlab画双坐标,如何利用matlab的plotyy函数画双坐标图??

热门文章

  1. html颜色代码生成器,在线取色配色工具,CSS3渐变色代码生成器-易玩稀有
  2. matlab qpsk调制 函数,MATLAB_QPSK调制与解调
  3. 2022华为杯数学建模A题思路代码
  4. win10蓝屏提示重新启动_Win10系统开机提示Winload.efi丢失的蓝屏问题怎么解决?
  5. docker安装,下载docker镜像
  6. Docker镜像下载到本地及恢复
  7. Chrome谷歌浏览器离线安装包下载
  8. 小爱音箱mini系统故障怎么办_小编处理win7系统连接小爱音箱mini的解决教程
  9. 2021靠谱的IT培训机构排名重磅来袭!
  10. 惠普打印机换硒鼓图解_hp硒鼓怎么安装 hp硒鼓安装方法这图文教程】