springboot项目中使用 Froala Editor 3,参考官网文档:https://www.froala.com/wysiwyg-editor/docs/overview

下载文件后,引入css和js

<link href="node_modules/froala-editor/css/froala_editor.pkgd.min.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="node_modules/froala-editor/js/froala_editor.pkgd.min.js"></script>

在页面中加入div

<div id="example"></div>

然后在页面总初始化:

<script type="text/javascript">
var editor = new FroalaEditor('#example',{
alwaysBlank: true,
language: 'zh_cn',
plainPaste: true,
imageButtons: ["floatImageLeft", "floatImageNone", "floatImageRight", "linkImage", "replaceImage", "removeImage"],
allowedImageTypes: ["jpeg", "jpg", "png", "gif"],
imageUploadURL: '../sys/oss/upload',
imageUploadParams: {id: "edit"},
imagesLoadURL: '../sys/oss/queryAll'
});
</script>

这样,页面上就能展示富文本了:

在提交富文本内容到数据库时,参考文档::https://www.froala.com/wysiwyg-editor/docs/methods#html.get

var editor = new FroalaEditor('.selector', {}, function () {
// Call the method inside the initialized event.
  editor.html.wrap(false, true, false);//包装表格处理 temp,tables,blockquote
  editor.html.get(true);//获取文本内容
})

然后将文本提交到后台,这时传递给后台的文本中带有被转义的字符,需要做特殊处理:

String content = newContent.replace("& lt;","<").replace("& gt;",">");

然后再做反转义处理,引入

<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-text</artifactId>
<version>1.6</version>
</dependency>
 content = StringEscapeUtils.unescapeHtml4(content);//反转义

这样就能正常保存到数据库了。

springboot 整合 Froala Editor 3的更多相关文章

  1. SpringBoot(七):SpringBoot整合Swagger2

    原文地址:https://blog.csdn.net/saytime/article/details/74937664 手写Api文档的几个痛点: 文档需要更新的时候,需要再次发送一份给前端,也就是文 ...

  2. SpringBoot整合Swagger2

    相信各位在公司写API文档数量应该不少,当然如果你还处在自己一个人开发前后台的年代,当我没说,如今为了前后台更好的对接,还是为了以后交接方便,都有要求写API文档. 手写Api文档的几个痛点: 文档需 ...

  3. SpringBoot整合Swagger和Actuator

    前言 本篇文章主要介绍的是SpringBoot整合Swagger(API文档生成框架)和SpringBoot整合Actuator(项目监控)使用教程. SpringBoot整合Swagger 说明:如 ...

  4. springboot 整合Swagger2的使用

    Swagger2相较于传统Api文档的优点 手写Api文档的几个痛点: 文档需要更新的时候,需要再次发送一份给前端,也就是文档更新交流不及时. 接口返回结果不明确 不能直接在线测试接口,通常需要使用工 ...

  5. Activiti工作流学习之SpringBoot整合Activiti5.22.0实现在线设计器(二)

    一.概述 网上有很多关于Eclipse.IDEA等IDE插件通过拖拽的方式来画工作流程图,个人觉得还是不够好,所以花点时间研究了一下Activiti在线设计器,并与SpringBoot整合. 二.实现 ...

  6. SpringBoot整合Shiro权限框架实战

    什么是ACL和RBAC ACL Access Control list:访问控制列表 优点:简单易用,开发便捷 缺点:用户和权限直接挂钩,导致在授予时的复杂性,比较分散,不便于管理 例子:常见的文件系 ...

  7. spring-boot整合mybatis(1)

    sprig-boot是一个微服务架构,加快了spring工程快速开发,以及简便了配置.接下来开始spring-boot与mybatis的整合. 1.创建一个maven工程命名为spring-boot- ...

  8. SpringBoot整合Mybatis之项目结构、数据源

    已经有好些日子没有总结了,不是变懒了,而是我一直在奋力学习springboot的路上,现在也算是完成了第一阶段的学习,今天给各位总结总结. 之前在网上找过不少关于springboot的教程,都是一些比 ...

  9. springboot整合mq接收消息队列

    继上篇springboot整合mq发送消息队列 本篇主要在上篇基础上进行activiemq消息队列的接收springboot整合mq发送消息队列 第一步:新建marven项目,配置pom文件 < ...

随机推荐

  1. go函数类型的使用

    Go函数类型的使用 type myfunc func() string // 声明函数变量 func main() { fn := func() string { return "bbb&q ...

  2. Jenkins 编译 .net 项目

    Jenkins 编译.net 项目 一.下载 windows jenkins 直接安装还是很方便的: https://mirrors.tuna.tsinghua.edu.cn/jenkins/wind ...

  3. cf 911F 树的直径+贪心

    $des$ 给定一棵 n 个节点的树,你可以进行 n ? 1 次操作,每次操作步骤如下:选择 u,v 两个度数为 1 的节点.将 u,v 之间的距离加到 ans 上.将 u 从树上删除.求一个操作序列 ...

  4. navicat 链接阿里云服务器数据库报80070007 的错误

    navicat用ssh跳转登录mysql连接时报: 80070007: SSH Tunnel: Server does not support diffie-hellman-group1-sha1 f ...

  5. jquery中$.get()如何让跨域请求携带cookie?

    在这个get请求前面加上这个就好了~~~~

  6. [转载] 浏览器Browser对同域名下的请求并发数量

    原文链接:https://blog.csdn.net/a562550212/article/details/79552713 另附原文作者贴的一个知乎地址,几个答主讲的非常好  https://www ...

  7. Hadoop(一)—— 启动与基本使用

    一.安装&启动 安装 下载hadoop2.7.2 https://archive.apache.org/dist/hadoop/common/hadoop-2.7.2/ 2.7.2-官方文档 ...

  8. Ubuntu -- unknown error: Chrome failed to start: exited abnormally (Driver info: chromedriver=...)

    #添加沙盒模式 chrome_options.add_argument("--no-sandbox")

  9. What are all the possible values for HTTP “Content-Type” header?

    What are all the possible values for HTTP “Content-Type” header? You can find every content type her ...

  10. 英语语法 - 介词on/in/at与时间

    介词滥用是中国学生的普遍缺点,主要是在语言学习的阶段没有人指正,形成有效的反馈,后面进入社会,就算别人发现你错了,也不会指正你,导致你一错再错. 看一篇教程,讲得不错.