FCKEditor2.6 For Jsp With FCKEditor-java-2.6

声明:在此只讨论FCKEditor2.6 For Jsp With FCKEditor-java-2.6的配置

一:从官方网站下载fckeditor核心文件ckeditor.com/download

二:下载java版的文件上传组件sourceforge.net/projects/fckeditor/files/FCKeditor.Java/2.6/

三:下载最后一个jar包www.slf4j.org/dist/ , 找到slf4j-1.5.8.zip,下载就行了

准备文件已全部下载好了,下面开始配置吧,

四:基本配置与优化 ,解压FCKeditor_2.6.5.zip,会得到一个文件夹fckeditor,全部 拷贝到工程的根目录下,只保留fckconfig.js,fckeditor.js,fckstyles.xml,fcktempletes.xml,和 fckeditor文件夹,删除所有以“_”开头的文件和文件夹 ,(这是测试或demo或是 temp文件,无用),

五: 解压fckeditor-java-2.6-bin.zip,拷贝fckeditor-java- core-2.6.jar和lib下的所有xx.jar到,你的项目/web-inf/lib下

六: 解压slf4j-1.5.8.zip,拷贝slf4j-jdk14-1.5.8.jar到,你的项目 /web-inf/lib下

七:编辑web.xml ,加入
<servlet>
   <servlet-name>FCKConnector</servlet-name>
   <servlet-class>net.fckeditor.connector.ConnectorServlet</servlet-class>
   <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
   <servlet-name>FCKConnector</servlet-name>
   <url-pattern>/fckeditor/editor/filemanager/connectors/*</url-pattern>
</servlet-mapping>

八:创建fckeditor.properties文件, 在src下(编译之后处于 classes目录中),加入
connector.userActionImpl = net.fckeditor.requestcycle.impl.UserActionImpl
注:default.properties可以在fckeditor-java-core-2.5.jar的net/fckeditor /handlers/找到

九:配置完毕 ,开始使用吧
js方式:
<script type="text/javascript" src="/fckeditor/fckeditor.js"></script>
<script type="text/javascript" language="javascript">
var oFCKeditor = new FCKeditor('content') ;
oFCKeditor.ToolbarSet = 'Basic';
oFCKeditor.Width = '100%';
oFCKeditor.Height = 600;
oFCKeditor.Value ='Hello Fckeditor 编辑器';
oFCKeditor.Create() ;
</script>

十:自定义FCKEditor ,找到fckconfig.js,打开
1:FCKConfig.SkinPath-----------------------------------皮肤
2:FCKConfig.DefaultLanguage------------------------语言(zh-cn and en )
并设置FCKConfig.AutoDetectLanguage = false ;
3:FCKConfig.ToolbarSets------------------------------自定义菜单
4:FCKConfig.EnterMode = 'br'-------------------------按下Enter时,换行
5:FCKConfig.ShiftEnterMode = 'p'--------------------按下Shift+Enter时,新段开始
6:FCKConfig.FontNames-------------------------------字体,可以添加

十一:开发相关
var obj = FCKeditorAPI.GetInstance('your fckeditor instanse name');
1: 获取带html标签的内容
(1)obj.GetXHTML(true); // "true" means you want it formatted.
(2)obj.EditorDocument.body.innerHTML
2: 追加与重置
(1)obj.InsertHtml()
(2)obj.SetData()
3: 获取text纯文本内容
obj.EditorDocument.body.innerText
4: 有关中文乱码
(1):打开%CATALINA_HOME%conf/server.xml,找到http/1.1协议,修改为:
<Connector port="8089" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" URIEncoding="UTF-8"/>
(2):在xx.html页面的head中加入<meta http-equiv="content-type" content="text/html; charset=UTF-8">
(3):要xx.jsp页面的第一行要确保有<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
(4):配置字符编码过滤器filter,设置为UTF-8
(5):还不行,最后就在接收端用字符转换吧,一定不再乱码了

5: 如何将从数据库中取到的值初始化到fckeditor中

<textarea name="news.content "><s:property value="news.content" escape="true"/></textarea>
<script type="text/javascript" language="javascript">
    var oFCKeditor = new FCKeditor('news.content ') ;
    oFCKeditor.ToolbarSet = 'Basic';
    oFCKeditor.Width = '100%';
    oFCKeditor.Height = 360;
    oFCKeditor.ReplaceTextarea();
</script>

注:一定要注意上下位置,不要错了啊,否则,后果自负

你可能感兴趣的:(JavaScript,jsp,servlet,fckeditor,basic,文件上传组件)