kindeditor加入方法

1.editor文件夹拷进来

2. editor里jsp子文件夹里找到几个jar拷贝到网站的web-app里的lib下

3.  网页里

head里加个这个

<link rel="stylesheet" href="editor/themes/default/default.css" />
    <link rel="stylesheet" href="editor/plugins/code/prettify.css" />
    <script charset="utf-8" src="editor/kindeditor-all.js"></script>
    <script charset="utf-8" src="editor/lang/zh-CN.js"></script>
    <script charset="utf-8" src="editor/plugins/code/prettify.js"></script>
    <script>
        KindEditor.ready(function(K) {
            var editor1 = K.create('textarea[name="content1"]', {
                cssPath : 'editor/plugins/code/prettify.css',
                uploadJson : 'editor/jsp/upload_json.jsp',
                fileManagerJson : 'editor/jsp/file_manager_json.jsp',
                allowFileManager : true,
                afterCreate : function() {
                    var self = this;
                    K.ctrl(document, 13, function() {
                        self.sync();
                        document.forms['example'].submit();
                    });
                    K.ctrl(self.edit.doc, 13, function() {
                        self.sync();
                        document.forms['example'].submit();
                    });
                }
            });
            prettyPrint();
        });
    </script>

body里加个显示的东西

  <textarea name="content1" cols="100" rows="8" style="700px;height:200px;visibility:hidden;"><%=htmlspecialchars(newscontent)%></textarea>  

html后面加一个

<%!
private String htmlspecialchars(String str) {
    str = str.replaceAll("&", "&amp;");
    str = str.replaceAll("<", "&lt;");
    str = str.replaceAll(">", "&gt;");
    str = str.replaceAll(""", "&quot;");
    return str;
}
%>

其中注意head标签里   “var editor1 = K.create('textarea[name="content1"]', {”       这个name值同你的textarea显示部分对应

具体可以参考其下jsp目录的demo.jsp

upload_json.jsp里可以修改文件上传类型

原文地址:https://www.cnblogs.com/pegasus827/p/8902418.html