CKEditor SpringMvc文件上传配置

config.js文件配置:

CKEDITOR.editorConfig = function( config ) {
    config.language = 'zh-cn';
    config.toolbar_MyBasic = [
        [ 'Bold', 'Italic','Underline', 'Strike'],
        ['FontSize','Image', 'helloworld']
    ];
    config.filebrowserImageUploadUrl='/api/paper/uploadMath?';
    config.extraPlugins += (config.extraPlugins ? ',helloworld' : 'helloworld');
    config.removePlugins = 'elementspath';
    config.resize_enabled = false;
    config.skin = 'moono-lisa';
};

Java代码:

 @RequestMapping("/uploadMath")
    public void uploadMath(@RequestParam MultipartFile upload,
                             HttpServletRequest request, HttpServletResponse response) throws IOException {
        PrintWriter out = response.getWriter();
        String CKEditorFuncNum = request.getParameter("CKEditorFuncNum");
        String fileName = upload.getOriginalFilename();
        String uploadContentType = upload.getContentType();
        String expandedName = "";
        if (uploadContentType.equals("image/pjpeg")
                || uploadContentType.equals("image/jpeg")) {
// IE6上传jpg图片的headimageContentType是image/pjpeg,而IE9以及火狐上传的jpg图片是image/jpeg
            expandedName = ".jpg";
        } else if (uploadContentType.equals("image/png")
                || uploadContentType.equals("image/x-png")) {
// IE6上传的png图片的headimageContentType是"image/x-png"
            expandedName = ".png";
        } else if (uploadContentType.equals("image/gif")) {
            expandedName = ".gif";
        } else if (uploadContentType.equals("image/bmp")) {
            expandedName = ".bmp";
        } else {
            out.println("");
            return;
        }
        if (upload.getSize() > 1024 * 1024 * 1) {
            out.println("");
            return;
        }

        String imgUrl= paperApiService.uploadMath(upload,request);
        out.println("");

        return;
    }

你可能感兴趣的:(CKEditor SpringMvc文件上传配置)