spring boot Ckeditor4上传图片

1、下载与加载

请参考文章:在线HTML编辑器 CKEditor4 下载及使用说明、演示实例

2、修改config.js文件

/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see https://ckeditor.com/legal/ckeditor-oss-license
 */
//原始js代码
//CKEDITOR.editorConfig = function( config ) {
//    // Define changes to default configuration here. For example:
//    // config.language = 'fr';
//    // config.uiColor = '#AADC6E';
//};
CKEDITOR.editorConfig = function( config ) {
//    config.extraPlugins = 'image2';
    config.toolbarGroups = [
        { name: 'document', groups: [ 'mode', 'document', 'doctools' ] },
        { name: 'clipboard', groups: [ 'clipboard', 'undo' ] },
        { name: 'editing', groups: [ 'find', 'selection', 'spellchecker', 'editing' ] },
        { name: 'forms', groups: [ 'forms' ] },
        '/',
        { name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ] },
        { name: 'paragraph', groups: [ 'list', 'indent', 'blocks', 'align', 'bidi', 'paragraph' ] },
        { name: 'links', groups: [ 'links' ] },
        { name: 'insert', groups: [ 'insert' ] },
        '/',
        { name: 'styles', groups: [ 'styles' ] },
        { name: 'colors', groups: [ 'colors' ] },
        { name: 'tools', groups: [ 'tools' ] },
        { name: 'others', groups: [ 'others' ] },
        { name: 'about', groups: [ 'about' ] }
    ];
    config.removeButtons = 
'Source,NewPage,Print,Templates,Find,Replace,Scayt,Form,Checkbox,Radio,TextField,Textarea,Select,Button,ImageButton,HiddenField,Superscript,Subscript,Strike,CopyFormatting,RemoveFormat,CreateDiv,Language,Anchor,Flash,Smiley,PageBreak,Iframe,ShowBlocks,Maximize,About,Save,Cut,Copy,Paste,HorizontalRule,PasteFromWord,PasteText';
    // 服务器端上传图片接口URL
    config.filebrowserImageUploadUrl='http://localhost:6666/images/CKEditorupload';  
    config.image_previewText=' ';     //预览区域显示内容   
};

3、spring boot后台:

实体类代码:

@Data
public class UploadImageResModel {
    /**
     * 1成功,0失败
     */
    private Integer uploaded;

    private String fileName;

    private String url;
}


控制器代码:

展开阅读全文

本文系作者在时代Java发表,未经许可,不得转载。

如有侵权,请联系nowjava@qq.com删除。

编辑于

关注时代Java

关注时代Java