首页 > 代码库 > Jfinal整合百度富文本编辑器ueditor

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

ueditor配置文件ueditor.config.js修改参数serverUrl:(改为要调用的controller)

技术分享

后台添加该路由指定的controller

package com.sandu.mega.admin.ueditor;

import com.jfinal.aop.Clear;
import com.jfinal.core.Controller;
import com.jfinal.kit.Ret;
import com.jfinal.upload.UploadFile;
import com.sandu.mega.common.kit.UploadOSSKit;
/**
 * 
* @ClassName: UeditorController
* @Description: TODO(百度富文本编辑器统一调用控制器 )
* @author suruozhong
* @date 2017年3月7日
*
 */
@Clear
public class UeditorController extends Controller {
    /**
     * ueditor上传
     */
    public void upload(){
        if ("config".equals(getPara("action"))) {
            render("/assets/ueditor/jsp/config.json");
            return;
        }
        UploadFile file = getFile("upfile");
        String fileName = file.getFileName();
        String[] typeArr = fileName.split("\\.");
        String orig = file.getOriginalFileName();
        long size = file.getFile().length();
        String url = UploadOSSKit.uploadImage(file);
        Ret ret = Ret.create("state", "SUCCESS")
                .set("url", url)
                .set("title", fileName)
                .set("original", orig)
                .set("type", "."+typeArr[1])
                .set("size", size);
        renderJson(ret);
    }
}

 

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