软件版本:kindeditor-4.1.9
初始化的参数配置:
1 <textarea id="editor_id" name="content" style="700px;height:300px;"> 2 <strong>HTML内容</strong> 3 </textarea> 4 5 <script charset="utf-8" src="/kEditor/kindeditor.js"></script> 6 <script charset="utf-8" src="/kEditor/lang/zh_CN.js"></script> 7 <script> 8 9 KindEditor.ready(function(K) { 10 11 var options = { 12 cssPath : '/css/index.css', 13 filterMode : true , 14 uploadJson : 'upload_json.jsp' , 15 fileManagerJson : 'file_manager_json.jsp' 16 }; 17 var editor = K.create('textarea[name="content"]', options); 18 19 }); 20 </script>
上传的图片、文件,保留原有文件名:修改 upload_json.jsp 文件,找到
String newFileName = df.format(new Date()) + "_" + new Random().nextInt(1000) + "." + fileExt;
修改成
String newFileName = df.format(new Date()) + "_" + new Random().nextInt(1000) + "." + fileName ;
效果如图:
编辑器中的 html 源码:
文本格式:
<img src="/KindEditor/attached/image/20131018/20131018175929_950.1_miketom155,有中文,有空 格.jpg" alt="" />
另外需要注意,你的 Web Server 一定要支持中文 URI ,我用的是 Tomcat ,需要在 Server.xml 文件中添加一个参数:
URIEncoding="utf-8"
1 <!-- A "Connector" represents an endpoint by which requests are received 2 and responses are returned. Documentation at : 3 Java HTTP Connector: /docs/config/http.html (blocking & non-blocking) 4 Java AJP Connector: /docs/config/ajp.html 5 APR (HTTP/AJP) Connector: /docs/apr.html 6 Define a non-SSL HTTP/1.1 Connector on port 8080 7 --> 8 <Connector URIEncoding="utf-8" connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8443"/> 9