1.下载
FCKeditor.java 2.3/FCKeditor-2.3.zip (FCKeditor for java)
FCKeditor_2.3b.zip (FCKeditor基本文件)
2.建立项目:Project/FCKeditor
3.FCKeditor.java FCKeditor-2.3.zip解压后,把其中的web目录下的WEB-INF目录copy到FCKeditor下(里面有commons-fileupload.jar, FCKeditor-2.3.jar,web.xml等几个文件), 把其中的src目录下的FCKeditor.tld文件copy到FCKeitor/WEB-INF/下
4.修改web.xml:
把SimpleUploader中的配置属性enabled定义为true(开启文件上传功能),加上editor所在目录, 下面红色是增加的部分
Connector
pattern>/[color=Red]FCKeditor[/color]/editor/filemanager/browser/default/connectors/jsp/connector
pattern>
SimpleUploader
/[color=Red]FCKeditor[/color]/editor/filemanager/upload/simpleuploader
添加标签定义:
/FCKeditor
/WEB-INF/FCKeditor.tld
5.解压FCKeditor_2.3b.zip后,把目录/editor和fckconfig.js, fckeditor.js, fckstyles.xml, fcktemplates.xml四个文件copy到/FCKeditor下
删除目录/editor/_source,
删除/editor/filemanager/browser/default/connectors/下的除了test.html外的所有文件夹
删除/editor/filemanager/upload/下除了test.html外的所有文件夹
删除/editor/lang/下的除了en.js, zh.js, zh-cn.js三个文件外的所有文件
6.打开/FCKeditor/fckconfig.js
修改 FCKConfig.DefaultLanguage = 'zh-cn' ;
把FCKConfig.LinkBrowserURL等的值替换成以下内容:
FCKConfig.LinkBrowserURL = FCKConfig.BasePath + "filemanager/browser/default/browser.html?Connector=connectors/jsp/connector" ;
FCKConfig.ImageBrowserURL = FCKConfig.BasePath + "filemanager/browser/default/browser.html?Type=Image&Connector=connectors/jsp/connector" ;
FCKConfig.FlashBrowserURL = FCKConfig.BasePath + "filemanager/browser/default/browser.html?Type=Flash&Connector=connectors/jsp/connector" ;
FCKConfig.LinkUploadURL = FCKConfig.BasePath + 'filemanager/upload/simpleuploader?Type=File' ;
FCKConfig.ImageUploadURL = FCKConfig.BasePath + 'filemanager/upload/simpleuploader?Type=Image' ;
FCKConfig.FlashUploadURL = FCKConfig.BasePath + 'filemanager/upload/simpleuploader?Type=Flash' ;
7.三种方法调用FCKeditor
(1).FCKeditor自定义标签 (必须加头文件 )
显示
toolbarSet = "Default" >
input
(2).script脚本语言调用 (必须引用 脚本文件 )
显示
input var oFCKeditor = new FCKeditor('content') ; oFCKeditor.BasePath = "/FCKeditor/" ; oFCKeditor.Height = 400; oFCKeditor.ToolbarSet = "Default" ; oFCKeditor.ReplaceTextarea(); |
(3).FCKeditor API 调用 (必须加头文件 )
FCKeditor oFCKeditor ;
oFCKeditor = new FCKeditor( request, "content" ) ;
oFCKeditor.setBasePath( "/FCKeditor/" ) ;
oFCKeditor.setValue( "input" );
out.println( oFCKeditor.create() ) ;
%>
8.输出:
String content = request.getParameter("content");
out.print(content);
%>
ok!
另:FCKeditor for Java的上传是通过servlet进行的,不是Jsp,所以配置文件web.xml中的"editor/filemanager/browser/default/connectors/jsp/connector" jsp/connector 目录并不存在,只要配置好FCKeditor.java就行了,最后上传非常快