KindEditor编辑框的内容上传

参考KindEditor的官方提供文档:

1.界面

<textarea id="content" name="content" style="width: 185px; height: 100px;">${content}</textarea>

2.javascript,可以根据自己的项目进行修改cssPath、uploadJson、fileManagerJson的路径。

<script type="text/javascript"> $(function() { var editor3 = KindEditor.create(textarea[name="content"], { resizeType : 1, allowPreviewEmoticons : false, allowImageRemote : false, filterMode : false, cssPath : ${ctx}/rel/js/kindeditor/plugins/code/prettify.css, uploadJson : ${ctx}/rel/js/kindeditor/jsp/upload_json.jsp, fileManagerJson : ${ctx}/rel/js/kindeditor/jsp/file_manager_json.jsp, allowFileManager : true, afterBlur : function() { this.sync(); }, items : [ source,fontname, fontsize, |, forecolor, hilitecolor, bold, italic, underline, removeformat, |, justifyleft, justifycenter, justifyright, insertorderedlist, insertunorderedlist, image, multiimage,link,unlink] }); }); </script>

3.copy lib文件夹中带的jar包到项目中

4. 按需求修改上面的upload_json.jsp和file_manager_json.jsp这两个文件的Java脚本代码即可。(也可以把其中的Java代码使用到java文件中使用)

经验分享 程序员 微信小程序 职场和发展