/******************************************
*Author:Java619
*Time:20070515
*******************************************/
首先下載相關文件
FCKeditor_2.3.2.zip
http://prdownloads.sourceforge.net/fckeditor/FCKeditor_2.3.2.zip?download
FCKeditor-2.3 (for java)
http://nchc.dl.sourceforge.net/sourceforge/fckeditor/FCKeditor-2.3.zip
1> 下載完成后,在J2EE應用中,建立項目:fcktest,在應用根目錄中建立文件夾FCKeditor,將FCKeditor中的editor目錄及 fckconfig.js、fckeditor.js、fckstyles.xml、fcktemplates.xml文件拷貝到FCKeditor目錄下。
2> 然后我們將FCKeditor-2.3\web\WEB-INF\lib中的兩個jar包拷貝到\fcktest\WEB-INF\lib目錄下,將 FCKeditor-2.3\src下的FCKeditor.tld拷貝到\fcktest\WEB-INF下。
3> 編輯\fcktest\WEB-INF\web.xml文件,將FCKeditor-2.3\web\WEB-INF\web.xml里的內容合并到項目的\WEB-INF\目錄下的web.xml文件中,修改<servlet-mapping>里的內容為:
<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> 修改合并后的web.xml文件,將名為SimpleUploader的Servlet的enabled參數值改為true,以允許上傳功能,Connector Servlet的baseDir參數值用于設置上傳文件存放的位置。
并添加下面內容
<taglib>
<taglib-uri>/FCKeditor</taglib-uri>
<taglib-location>/WEB-INF/FCKeditor.tld</taglib-location>
</taglib>
5>修改頁面fckconfig.js
將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';
6> 添加頁面 index.jsp
<%@page contentType="text/html;charset=UTF-8"%>
<%@page pageEncoding="UTF-8"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
<script type="text/javascript" src="FCKeditor/fckeditor.js"></script>
</head>
<body>
<form action="sampleposteddata.jsp" method="post" target="_blank">
<table border="0" width="700"><tr><td>
<textarea id="content" name="content" style="WIDTH: 100%; HEIGHT: 400px"></textarea>
<script type="text/javascript">
var oFCKeditor = new FCKeditor('content') ;
oFCKeditor.BasePath = "FCKeditor/" ;
oFCKeditor.Height = 400;
oFCKeditor.ReplaceTextarea();
</script>
<input type="submit" value="Submit">
</td></tr></table>
</form>
</body>
</html>
7> 添加接受頁面sampleposteddata.jsp
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ page language="java" import="java.util.*" %>
<%
Enumeration params = request.getParameterNames();
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<html>
<head>
<title>FCKeditor - Samples - Posted Data</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="robots" content="noindex, nofollow">
<link href="../sample.css" rel="stylesheet" type="text/css" />
</head>
<body>
<h1>FCKeditor中國的中 - Samples - Posted Data</h1>
This page lists all data posted by the form.
<hr>
<table width="100%" border="1" cellspacing="0" bordercolor="#999999">
<tr style="FONT-WEIGHT: bold; COLOR: #dddddd; BACKGROUND-COLOR: #999999">
<td noWrap>Field Name </td>
<td>Value</td>
</tr>
<%
String parameter = null ;
while( params.hasMoreElements() )
{
parameter = (String) params.nextElement() ;
%>
<tr>
<td valign="top" nowrap><b><%=parameter%></b></td>
<td width="100%"><%=request.getParameter(parameter)%></td>
</tr>
<%
}
%>
</table>
</body>
</html>