若依前后台分离版-集成ueditor实现富文本编辑器增强详细教程

张开发
2026/6/12 9:51:35 15 分钟阅读
若依前后台分离版-集成ueditor实现富文本编辑器增强详细教程
集成ueditor实现富文本编辑器前言一、准备工作二、集成1.将UEditor前端插件放入项目框架中:2.编写UeditorController3.添加组件EditorBaidu三、其他问题汇总(上传、回显...)总结前言若依框架是一个极速后台开发框架,使用起来非常方便。但是自带的编辑器功能与百度编辑器对比功能相对而言匮乏,因此项目需要整合ueditor实现富文本编辑器。一、准备工作1.下载UEditor前端插件提示:官方集成教程为前后端不分离版,也可自行前往参考2.若依框架代码下载若依官网:http://ruoyi.vip(opens new window)演示地址:http://vue.ruoyi.vip(opens new window)代码下载:https://gitee.com/y_project/RuoYi-Vue二、集成1.将UEditor前端插件放入项目框架中:2.编写UeditorController提示:使用包中UeditorController类时在线上部署时读不到配置,所有我改了一下,使用时可自需修改@RestController @RequestMapping("/ueditor")public class UeditorController extends BaseController{@Autowired private ServerConfig serverConfig;privatestaticfinal String FILE_DELIMETER=",";@Anonymous @GetMapping public StringgetConfig(){String configContent=null;try{configContent=this.readFile("ueditor-config.json");}catch(IOException e){e.printStackTrace();}returnconfigContent;}private StringreadFile(String path)throws IOException{StringBuilder builder=newStringBuilder();try{// 在这里并没有使用传进来的path,// 而是使用spring的ClassPathResource来加载文件// 防止打包方式为jar时,找不到文件的问题ClassPathResource resource=newClassPathResource("ueditor-config.json");InputStreamReader reader=newInputStreamReader(resource.getInputStream(),"UTF-8");BufferedReader bfReader=newBufferedReader(reader);String tmpContent=null;while((tmpContent=bfReader.readLine())!=null){builder.append(tmpContent);}bfReader.close(

更多文章