1. 程式人生 > >Springboot零配置整合UEditor

Springboot零配置整合UEditor

         1.建立Springboot專案,目錄結構如下

          

        2.pom檔案引入

  1. <dependency>
        <groupId>cn.jasonone.ueditor</groupId>
    	<artifactId>ueditor-spring-boot-starter</artifactId>
    	<version>1.1.0</version>
    </dependency>

    3. Springboot application.yml配置(可選配置)

  2. 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配置(必選)

  1. //...
    //伺服器統一請求介面路徑
    , serverUrl: URL + "jsp/controller"
    //...

          5.HTML程式碼(index.html)

  1. <!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>