springboot整合ueditor百度富文本编辑器

第一步:到官方下载ueditor

https://ueditor.baidu.com/website/download.html#ueditor(ueditor下载地址)

gitee项目地址:https://gitee.com/jalyson/lucky.git

github项目地址:https://github.com/jalyson/lucky.git

下载后,运行访问http://127.0.0.1:8080/ueditor/index

springboot整合ueditor百度富文本编辑器_第1张图片

第二步:添加maven依赖

springboot整合ueditor百度富文本编辑器_第2张图片

把jsp里面的config.json放到外层,jsp文件夹就没用了可以删除。

在pom.xml加入 (jsp里面的依赖)

#注意:springboot框架层一般会有commons-fileupload等其它依赖jar,因此只需要ueditor依赖即可

!-- https://mvnrepository.com/artifact/com.gitee.qdbp.thirdparty/ueditor -->

    com.gitee.qdbp.thirdparty
    ueditor
    1.4.3.3

完整的依赖如下:

springboot整合ueditor百度富文本编辑器_第3张图片

第三步:添加ueditor server控制器

springboot整合ueditor百度富文本编辑器_第4张图片

/**
 * ueditor Server
 */
@RequestMapping(value = "/ueditorServer")
public void ueditor(HttpServletRequest request, HttpServletResponse response) {
    try {
        request.setCharacterEncoding( "utf-8" );
        response.setContentType("application/json");
        //配置文件config文件路径,     同时也是富文本编辑器上传文件的路径
        String rootPath = ClassUtils.getDefaultClassLoader().getResource("").getPath() + "static/ueditor";
        System.out.println("rootPath="+rootPath);
        ///rootPath=D:/workspace/testspace/exercise-html/target/classes/static/ueditor
        String exec = new ActionEnter(request, rootPath).exec();
        System.out.println(exec);
        response.getWriter().write(exec );
    } catch (Exception e) {

    }
}

 

第四步:修改ueditor配置

 

1.修改ueditor.config.js

 

springboot整合ueditor百度富文本编辑器_第5张图片

springboot整合ueditor百度富文本编辑器_第6张图片

"imageUrlPrefix": "http://127.0.0.1:8080/static/ueditor", /* 图片访问路径前缀   这个是配置要注意,配错了,图片无法显示*/
"imagePathFormat": "/upload/image/{yyyy}{mm}{dd}/{time}{rand:6}", /* 上传保存路径,可以自定义保存路径和文件名格式 这个改不改无所谓 */

这个配置是上传图片的,下面还有其它的(涂鸦图片上传配置项、截图工具上传等等),有用到相应功能时,也要跟着修改。

第五步,编辑器的使用

 

springboot整合ueditor百度富文本编辑器_第7张图片

 

 

如果对你有帮助请打赏点消费

 

你可能感兴趣的:(前端,富文本框编辑器,ueditor)