乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      SpringBoot集成百度UEditor

       三十的狼 2019-09-30

      UEditor簡(jiǎn)介

      UEditor是由百度web前端研發(fā)部開發(fā)所見即所得富文本web編輯器,具有輕量,可定制,注重用戶體驗(yàn)等特點(diǎn),開源基于MIT協(xié)議,允許自由使用和修改代碼
      官網(wǎng):https://ueditor.baidu.com/

      UEditor分類

      UEeditor(官網(wǎng)上的開發(fā)版)
      Github地址:https://github.com/fex-team/ueditor
      官方文檔地址:http://fex.baidu.com/ueditor/

      image.png

      另一個(gè)是UMeditor(mini版)
      Github地址:https://github.com/fex-team/umeditor

      image.png

      UMeditor,簡(jiǎn)稱UM,是ueditor的簡(jiǎn)版。是為滿足廣大門戶網(wǎng)站對(duì)于簡(jiǎn)單發(fā)帖框和回復(fù)框的需求,專門定制的在線富文本編輯器。

      UEditor/UMeditor主要特點(diǎn)

      1.輕量: 主文件的代碼量為139k。
      2.加載速度更快: 放棄了使用傳統(tǒng)的iframe模式,采用了div的加載方式,以達(dá)到更快的加載速度和零加載失敗率。
      3.可定制: 配置項(xiàng)完善,可定制程度高。
      4.可擴(kuò)展: 代碼層次拆分清晰,功能以插件形式掛接,可靈活定制需要的功能。
      5.多后臺(tái)支持: 支持php、asp、jsp、.net四種后臺(tái)部署代碼
      6.功能豐富: 支持插入公式、粘貼QQ截屏、拖放上傳圖片、插入地圖、草稿箱功能

      與SpringBoot進(jìn)行集成

      由于整合的是前端框架,所以u(píng)editor官方并沒有jar包傳到maven倉(cāng)庫
      引入ueditor包的源碼地址:
      https://github.com/weiangongsi/ueditor-spring-boot-starter

      <dependency>
          <groupId>com.dcssn</groupId>
          <artifactId>ueditor-spring-boot-starter</artifactId>
          <version>0.0.1</version>
      </dependency>
      <dependency>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-starter-thymeleaf</artifactId>
      </dependency>
      <dependency>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-starter-web</artifactId>
      </dependency>
      

      下載UEditor源碼

      UEditor/UMeditor源碼下載地址https://ueditor.baidu.com/website/download.html

      image.png

      Java下載JSP版本的就可以了,下載解壓后你會(huì)發(fā)現(xiàn)有html,css,js,圖片等靜態(tài)資源,直接在static靜態(tài)資源目錄下創(chuàng)建個(gè)ueditor目錄,然后把解壓出來的靜態(tài)資源都放進(jìn)去就可以了

      image.png

      這里說下jsp目錄

      image.png

      jsp里面包含了Java集成ueditor會(huì)用到的一些Jar包還有一個(gè)JSP頁面,這里用thymeleaf模板代替就不需要JSP了,由于引入了第三方ueditor依賴。所以可以把lib文件夾和jsp頁面都刪掉

      重點(diǎn)說明

      要重點(diǎn)注意config.jsonueditor.config.js兩個(gè)文件
      config.json
      圖片訪問路徑前綴imageUrlPrefix、視頻訪問路徑前綴videoUrlPrefix、文件訪問路徑前綴fileUrlPrefix不要賦值,會(huì)影響回顯,其余參數(shù)可以按照百度文檔修改
      ueditor.config.js
      serverUrl 改為yml配置文件中ue.server-url 的值

      image.png

      yml配置文件如下

      spring:
        servlet:
          multipart:
            max-file-size: 100MB
      ue:
        config-file: static/ueditor/jsp/config.json 
        server-url: /ueditor.do 
        url-prefix: /file
      

      ue.url-prefix= /file用于回顯圖片,不設(shè)置的話后顯示不出上傳的圖片
      Spring上傳文件默認(rèn)最大1MB,上傳文件大小會(huì)先被Spring限制,config.json文件大小限制要小于Spring的設(shè)置,可以將Spring的限制設(shè)大點(diǎn)

      編寫controller和thymeleaf頁面

      @GetMapping("/")
          public String index() {
              return "ue";
          }
      

      主要用來頁面跳轉(zhuǎn),別忘了在類上加個(gè)@Controller注解

      <!DOCTYPE html>
      <html lang="UTF-8" xmlns:th="http://www./schema/jdbc">
      <head>
          <meta charset="UTF-8"/>
          <title>ueditor</title>
          <style>
              #editor {
                  width: 1024px;
                  height: 500px;
              }
          </style>
      </head>
      <body>
      <div id="editor" type="text/plain"></div>
      <script th:src="@{/ueditor/ueditor.config.js}"></script>
      <script th:src="@{/ueditor/ueditor.all.min.js}"></script>
      <script th:src="@{/ueditor/lang/zh-cn/zh-cn.js}"></script>
      <script>
          UE.getEditor('editor');
      </script>
      </body>
      </html>
      

      UE.getEditor('editor')ueditor.all.js中,用于得到UEditor編輯器實(shí)例

      測(cè)試啟動(dòng)

      訪問http://localhost:8080/

      image.png

      成功看到UEditor編輯器界面說明集成成功

      文件存儲(chǔ)路徑

      每次上傳文件,圖片,或者視頻,都會(huì)在項(xiàng)目對(duì)應(yīng)的磁盤下生成ueditor文件夾
      存儲(chǔ)格式路徑其實(shí)在config.json中都可以設(shè)置的,在config.json中搜索PathFormat關(guān)鍵字就可以找到各種文件的路徑設(shè)置
      Window
      比如說你的項(xiàng)目在D盤,有上傳文件的話就會(huì)在D盤自動(dòng)生成ueditor文件夾用于本地存儲(chǔ)
      Linux服務(wù)器
      ueditor文件夾就會(huì)在根路徑生成

        本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
        轉(zhuǎn)藏 分享 獻(xiàn)花(0

        0條評(píng)論

        發(fā)表

        請(qǐng)遵守用戶 評(píng)論公約

        類似文章 更多