开发环境:
Tomcat6.0 MyEclipse 5.1.1
FCKeditor 版本 FCKeditor_2.5 FCKeditor.Java 2.3
下载地址: http://www.fckeditor.net/download/default.html
开始:
新建工程,名称为 FCKeditor
解压 FCKeditor_2.5 包中的 edit 文件夹到项目中的 WebRoot\fck目录
解压 FCKeditor_2.5 包中的 fckconfig.js、fckeditor.js、fckstyles.xml、fcktemplates.xml 文件夹到项目中的 WebRoot\fck目录
解压 FCKeditor-2.3.zip 包中的 \web\WEB-INF\lib 下的两个 jar 文件到项目的 WebRoot\WEB-INF\lib 目录
解压 FCKeditor-2.3.zip 包中的 \src 下的 FCKeditor.tld 文件到项目的 WebContent\WEB-INF 目录
刷新一下工程,有一个文件会出错,不管它是什么错,将错误信息清除
删除 WebContent\edit 目录下的 _source 文件夹
修改 web.xml 文件,加入以下内容
代码
<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>
<!-- 此为文件上传路径,需要在WebRoot 目录下新建 UserFiles 文件夹 -->
<!-- 根据文件的类型还需要新建相关的文件夹 Image、 Flash -->
<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>false</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/fck/editor/filemanager/browser/default/connectors/jsp/connector</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>SimpleUploader</servlet-name>
<url-pattern>/FCKeditor/fck/editor/filemanager/upload/simpleuploader</url-pattern>
</servlet-mapping>
新建一个提交页 test.jsp 文件和一个接收页 show.jsp 文件
test.jsp 代码如下:
代码
<%@ page contentType = "text/html;charset=UTF-8" language = "java" %>
<%@ taglib uri = "/WEB-INF/FCKeditor.tld" prefix = "fck" %><html>
<head>
<title> Test </title>
</head> <body>
<FORM action = "test1.jsp" >
<fck:editor id = "testfck" basePath = "/FCKeditor/fck/"
height = "100%"
skinPath = "/FCKeditor/fck/editor/skins/default/"
toolbarSet = "Default"
imageBrowserURL = "/FCKeditor/fck/editor/filemanager/browser/default/browser.html?Type=Image&Connector=connectors/jsp/connector"
linkBrowserURL = "/FCKeditor/fck/editor/filemanager/browser/default/browser.html?Connector=connectors/jsp/connector"
flashBrowserURL = "/FCKeditor/fck/editor/filemanager/browser/default/browser.html?Type=Flash&Connector=connectors/jsp/connector"
imageUploadURL = "/FCKeditor/fck/editor/filemanager/upload/simpleuploader?Type=Image"
linkUploadURL = "/FCKeditor/fck/editor/filemanager/upload/simpleuploader?Type=File"
flashUploadURL = "/FCKeditor/fck/editor/filemanager/upload/simpleuploader?Type=Flash" >
</fck:editor>
<input type="submit" />
</FORM>
</body>
</html>
show.jsp 代码如下:
<html>
<head>
<title>TEST</title>
</head> <body>
<%=request.getParameter( "testfck" )%>
</body>
</html>
在 WebRoot 目录下新建 UserFiles 文件夹,在此文件夹下新建 Image 和 Flash 两个文件夹
这样就可以测试了
参考http://www.blogjava.net/oksonic/archive/2006/05/11/45687.aspx