UEditor

UEditor的工作原理:

上传后将数据将图片的访问地址等等信息传回来。

var URL = window.UEDITOR_HOME_URL || getUEBasePath();

将window.UEDITOR_HOME_URL设置为UEditor的目录。


// 服务器统一请求接口路径
        , serverUrl: ROOT_PATH + "file/upload"

这里将serverUrl设置一下,设置为自己的上传方法。

@RequestMapping(value = "/upload", method = GET)
    @ResponseBody
    public void upload(HttpServletRequest request, HttpServletResponse response) throws IOException {
        String action = request.getParameter("action");
        if ("config".equals(action)) {
            OutputStream os = response.getOutputStream();
            IOUtils.copy(XX.class.getClassLoader().getResourceAsStream("ueditor-config.json"), os);
        }
    }

加载config.json,配置

@RequestMapping(value = "/upload", method = POST)
    @ResponseBody
    public Map<String, String> upload(@RequestParam CommonsMultipartFile Filedata, HttpServletRequest request) throws IOException {
        //返回类型
        result.put("url", url);
        result.put("size", String.valueOf(file.length()));
        result.put("type", fileName.substring(fileName.lastIndexOf(".")));
        result.put("state", "SUCCESS");
        return result;
    }


你可能感兴趣的:(UEditor)