1、首先登陆www.fckeditor.net/download下载FCKeditor的最新版本,需要下载2个压缩包,一个是基本应用,另一个是在为在jsp下所准备的配置。
FCKeditor 2.6 下载地址:sourceforge.net/project/downloading.php
FCKeditor.Java 下载地址:sourceforge.net/project/downloading.php
下载之后分别为:FCKeditor_2.6.zip 和 FCKeditor-2.3.zip 将它们分别解压。
2、首先在Eclipse下建立一个新项目例如:test 即http://localhost:8080/test
在项目中新建文件夹 FCKeditor,然后将解压后的FCKeditor_2.6下fckeditor里面的editor、fckconfig.js、fckeditor.js、fckstyles.xml、fcktemplates.xml拷贝到FCKeditor目录下
将解压后的FCKeditor-2.3文件夹中web/WEB-INF/lib下的包拷贝到test项目的lib中。
将FCKeditor-2.3文件夹下src下的FCKeditor.tld拷贝到test项目的WEB-INF下。
3、将WEB-INF下的web.xml 加入如下内容:
- <STRONG> <servlet>
- <servlet-name>Connector</servlet-name>
- <servlet-class>com.fredck.FCKeditor.connector.ConnectorServlet</servlet-class>
- <init-param>
- <param-name>baseDir</param-name>
- <param-value>/UserFiles/</param-value>
- </init-param>
- <init-param>
- <param-name>debug</param-name>
- <param-value>true</param-value>
- </init-param>
- <load-on-startup>1</load-on-startup>
- </servlet>
- <servlet>
- <servlet-name>SimpleUploader</servlet-name>
- <servlet-class>com.fredck.FCKeditor.uploader.SimpleUploaderServlet</servlet-class>
- <init-param>
- <param-name>baseDir</param-name>
- <param-value>/UserFiles/</param-value>
- </init-param>
- <init-param>
- <param-name>debug</param-name>
- <param-value>true</param-value>
- </init-param>
- <init-param>
- <param-name>enabled</param-name>
- <param-value>true</param-value>
- </init-param>
- <init-param>
- <param-name>AllowedExtensionsFile</param-name>
- <param-value></param-value>
- </init-param>
- <init-param>
- <param-name>DeniedExtensionsFile</param-name>
- <param-value>php|php3|php5|phtml|asp|aspx|ascx|jsp|cfm|cfc|pl|bat|exe|dll|reg|cgi</param-value>
- </init-param>
- <init-param>
- <param-name>AllowedExtensionsImage</param-name>
- <param-value>jpg|gif|jpeg|png|bmp</param-value>
- </init-param>
- <init-param>
- <param-name>DeniedExtensionsImage</param-name>
- <param-value></param-value>
- </init-param>
- <init-param>
- <param-name>AllowedExtensionsFlash</param-name>
- <param-value>swf|fla</param-value>
- </init-param>
- <init-param>
- <param-name>DeniedExtensionsFlash</param-name>
- <param-value></param-value>
- </init-param>
- <load-on-startup>1</load-on-startup>
- </servlet>
- <servlet-mapping>
- <servlet-name>Connector</servlet-name>
- <url-pattern>/FCKeditor/editor/filemanager/browser/default/connectors/jsp/connector</url-pattern>
- </servlet-mapping>
- <servlet-mapping>
- <servlet-name>SimpleUploader</servlet-name>
- <url-pattern>/FCKeditor/editor/filemanager/upload/simpleuploader</url-pattern>
- </servlet-mapping></STRONG>
- <STRONG> <servlet>
- <servlet-name>Connector</servlet-name>
- <servlet-class>com.fredck.FCKeditor.connector.ConnectorServlet</servlet-class>
- <init-param>
- <param-name>baseDir</param-name>
- <param-value>/UserFiles/</param-value>
- </init-param>
- <init-param>
- <param-name>debug</param-name>
- <param-value>true</param-value>
- </init-param>
- <load-on-startup>1</load-on-startup>
- </servlet>
- <servlet>
- <servlet-name>SimpleUploader</servlet-name>
- <servlet-class>com.fredck.FCKeditor.uploader.SimpleUploaderServlet</servlet-class>
- <init-param>
- <param-name>baseDir</param-name>
- <param-value>/UserFiles/</param-value>
- </init-param>
- <init-param>
- <param-name>debug</param-name>
- <param-value>true</param-value>
- </init-param>
- <init-param>
- <param-name>enabled</param-name>
- <param-value>true</param-value>
- </init-param>
- <init-param>
- <param-name>AllowedExtensionsFile</param-name>
- <param-value></param-value>
- </init-param>
- <init-param>
- <param-name>DeniedExtensionsFile</param-name>
- <param-value>php|php3|php5|phtml|asp|aspx|ascx|jsp|cfm|cfc|pl|bat|exe|dll|reg|cgi</param-value>
- </init-param>
- <init-param>
- <param-name>AllowedExtensionsImage</param-name>
- <param-value>jpg|gif|jpeg|png|bmp</param-value>
- </init-param>
- <init-param>
- <param-name>DeniedExtensionsImage</param-name>
- <param-value></param-value>
- </init-param>
- <init-param>
- <param-name>AllowedExtensionsFlash</param-name>
- <param-value>swf|fla</param-value>
- </init-param>
- <init-param>
- <param-name>DeniedExtensionsFlash</param-name>
- <param-value></param-value>
- </init-param>
- <load-on-startup>1</load-on-startup>
- </servlet>
- <servlet-mapping>
- <servlet-name>Connector</servlet-name>
- <url-pattern>/FCKeditor/editor/filemanager/browser/default/connectors/jsp/connector</url-pattern>
- </servlet-mapping>
- <servlet-mapping>
- <servlet-name>SimpleUploader</servlet-name>
- <url-pattern>/FCKeditor/editor/filemanager/upload/simpleuploader</url-pattern>
- </servlet-mapping></STRONG>
<servlet> <servlet-name>Connector</servlet-name> <servlet-class>com.fredck.FCKeditor.connector.ConnectorServlet</servlet-class> <init-param> <param-name>baseDir</param-name> <param-value>/UserFiles/</param-value> </init-param> <init-param> <param-name>debug</param-name> <param-value>true</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet> <servlet-name>SimpleUploader</servlet-name> <servlet-class>com.fredck.FCKeditor.uploader.SimpleUploaderServlet</servlet-class> <init-param> <param-name>baseDir</param-name> <param-value>/UserFiles/</param-value> </init-param> <init-param> <param-name>debug</param-name> <param-value>true</param-value> </init-param> <init-param> <param-name>enabled</param-name> <param-value>true</param-value> </init-param> <init-param> <param-name>AllowedExtensionsFile</param-name> <param-value></param-value> </init-param> <init-param> <param-name>DeniedExtensionsFile</param-name> <param-value>php|php3|php5|phtml|asp|aspx|ascx|jsp|cfm|cfc|pl|bat|exe|dll|reg|cgi</param-value> </init-param> <init-param> <param-name>AllowedExtensionsImage</param-name> <param-value>jpg|gif|jpeg|png|bmp</param-value> </init-param> <init-param> <param-name>DeniedExtensionsImage</param-name> <param-value></param-value> </init-param> <init-param> <param-name>AllowedExtensionsFlash</param-name> <param-value>swf|fla</param-value> </init-param> <init-param> <param-name>DeniedExtensionsFlash</param-name> <param-value></param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>Connector</servlet-name> <url-pattern>/FCKeditor/editor/filemanager/browser/default/connectors/jsp/connector</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>SimpleUploader</servlet-name> <url-pattern>/FCKeditor/editor/filemanager/upload/simpleuploader</url-pattern> </servlet-mapping>
4、修改FCKeditor文件夹下的fckeditor.js
修改第50行的FCKeditor.BasePath。
改之后:
- 50 FCKeditor.BasePath = 'FCKeditor/' ;
- 50 FCKeditor.BasePath = 'FCKeditor/' ;
50 FCKeditor.BasePath = 'FCKeditor/' ;
5、修改FCKeditor文件夹下的fckconfig.js
修改FCKConfig.DefaultLanguage、FCKConfig.LinkBrowserURL、FCKConfig.ImageBrowserURL、FCKConfig.FlashBrowserURL、
改之后:
- FCKConfig.DefaultLanguage = 'zh-cn' ;
- FCKConfigFCKConfig.LinkBrowserURL = FCKConfig.BasePath + "filemanager/browser/default/browser.html?Connector=connectors/jsp/connector" ;
- FCKConfigFCKConfig.ImageBrowserURL = FCKConfig.BasePath + "filemanager/browser/default/browser.html?Type=Image&Connector=connectors/jsp/connector" ;
- FCKConfigFCKConfig.FlashBrowserURL = FCKConfig.BasePath + "filemanager/browser/default/browser.html?Type=Flash&Connector=connectors/jsp/connector" ;
- FCKConfigFCKConfig.LinkUploadURL = FCKConfig.BasePath + 'filemanager/upload/simpleuploader?Type=File' ;
- FCKConfigFCKConfig.ImageUploadURL = FCKConfig.BasePath + 'filemanager/upload/simpleuploader?Type=Image' ;
- FCKConfigFCKConfig.FlashUploadURL = FCKConfig.BasePath + 'filemanager/upload/simpleuploader?Type=Flash' ;
- FCKConfig.DefaultLanguage = 'zh-cn' ;
- FCKConfigFCKConfig.LinkBrowserURL = FCKConfig.BasePath + "filemanager/browser/default/browser.html?Connector=connectors/jsp/connector" ;
- FCKConfigFCKConfig.ImageBrowserURL = FCKConfig.BasePath + "filemanager/browser/default/browser.html?Type=Image&Connector=connectors/jsp/connector" ;
- FCKConfigFCKConfig.FlashBrowserURL = FCKConfig.BasePath + "filemanager/browser/default/browser.html?Type=Flash&Connector=connectors/jsp/connector" ;
- FCKConfigFCKConfig.LinkUploadURL = FCKConfig.BasePath + 'filemanager/upload/simpleuploader?Type=File' ;
- FCKConfigFCKConfig.ImageUploadURL = FCKConfig.BasePath + 'filemanager/upload/simpleuploader?Type=Image' ;
- FCKConfigFCKConfig.FlashUploadURL = FCKConfig.BasePath + 'filemanager/upload/simpleuploader?Type=Flash' ;
FCKConfig.DefaultLanguage = 'zh-cn' ; 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' ;
6、default.jsp内容如下:
- <%@ page language="java" contentType="text/html; charset=gb2312"
- pageEncoding="gb2312"%>
- <%@ taglib prefix="s" uri="/struts-tags"%>
- <%@ taglib prefix="fck" uri="/WEB-INF/FCKeditor.tld"%>
- <%request.setCharacterEncoding("gb2312");%>
- <html>
- <head>
- <title