1.创建Springboot项目,目录结构如下
2.pom文件引入
-
<dependency> <groupId>cn.jasonone.ueditor</groupId> <artifactId>ueditor-spring-boot-starter</artifactId> <version>1.2.2</version> </dependency>
3. Springboot 配置
-
Java配置(必选)
@SpringBootApplication @EnableUeditor //启用Ueditor //@EnableUeditor(LocationFileStorage.class) //启用Ueditor并指定文件持久化类 public class UeditorSpringBootExampleApplication { public static void main(String[] args) { SpringApplication.run(UeditorSpringBootExampleApplication.class, args); } }
-
application.yml配置(可选)
ue: root-path: classpath:/static #文件存储根目录(可选配置),默认为[classpath:/static] server-url: /ueditor/jsp/controller #服务器统一请求接口路径(可选配置),默认为[/ueditor/jsp/controller]
注意: config.json 文件位置默认为server-url的上级目录,如server-url=/ueditor/jsp/controller 则config.json文件应该存放于 ${root-path}/ueditor/jsp/config.json
4.UEditor配置(必选)
- static/ueditor/ueditor.config.js 将serverUrl 改为application.yml 中ue.server-url 的值
-
//... //服务器统一请求接口路径 , serverUrl: URL + "jsp/controller" //...
5.HTML代码(index.html)
-
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Insert title here</title> </head> <body> <script type="text/plain" id="editor"></script> <script th:src="@{/ueditor/ueditor.config.js}"></script> <script th:src="@{/ueditor/ueditor.all.js}"></script> <script th:src="@{/ueditor/lang/zh-cn/zh-cn.js}"></script> <script> UE.getEditor('editor'); </script> </body> </html>
版本历史
- 1.1.3
- 修复自定义文件持久化对象不生效问题#IXCR4
- 修复错误:Unable to read meta-data for class
- 1.2.0
- 使用全新的持久化接口(cn.jasonone.upload.UeditorStorate)代替cn.jasonone.upload.UeditorUpload接口
- 简化自定义持久化接口的定义
- 修改启用方式为使用@EnableUeditor注解启用
- 修复缺少配置文件时无提示问题#I12KGP
- 自定义文件持久化对象配置方式变更为注解设置
- 1.2.2
- 修复使用默认rootPath配置报错的问题 #I1GO02
项目地址:https://gitee.com/hmjasonone/ueditor-spring-boot-stater