1.建立Springboot項目,目錄結構以下(在resources中static/ueditor/jsp/config.json)
2.pom文件引入
<dependency> <groupId>cn.jasonone.ueditor</groupId> <artifactId>ueditor-spring-boot-starter</artifactId> <version>1.1.4</version> </dependency>
3. Springboot application.yml配置(可選配置)
ue: root-path: classpath:/static #文件存儲根目錄(可選配置),默認爲[classpath:/static] server-url: /ueditor/jsp/controller #服務器統一請求接口路徑(可選配置),默認爲[/ueditor/jsp/controller] upload: cn.jasonone.ueditor.upload.LocationFileStorage #文件持久化處理類(可選配置),默認爲[cn.jasonone.ueditor.upload.LocationFileStorage]
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>
項目地址:https://gitee.com/hmjasonone/ueditor-spring-boot-staterjavascript
錯誤:Unable to read meta-data for class com.jason.ueditor.UeditorAutoConfiguration 出錯版本: 1.1.0 解決辦法: 將Jar包更新到1.1.3版本