在JSP中使用 FCKeditor
1.1運行庫 commons-fileupload-1.1.jar FCKeditor-2.3.jar 1.2編輯器版本 FCKeditor 2.0 FCKeditor 是一套線上編輯器,它幾乎囊括了現在網上所有的線上編輯器的功能,功能的實現相當完善,同時可自由定製功能按鈕,支援多種語言環境下配置安裝
1.3使用步驟 1.3.1 Web 應用程式目錄結構
1.3.2配置說明 <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<display-name>demo</display-name>
<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>false</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>AllowedExtensionsFlash</param-name><!—允許上傳Flash類型清單-->
<param-value>swf|fla</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映射-->
</servlet-mapping>
<servlet-mapping>
<servlet-name>SimpleUploader</servlet-name>
<url-pattern>/FCKeditor/editor/filemanager/upload/simpleuploader</url-pattern>
</servlet-mapping><!—用於上傳檔案的servlet映射-->
<taglib>
<taglib-uri>FCK</taglib-uri><!—標籤庫映射-->
<taglib-location>/WEB-INF/classes/FCKeditor.tld</taglib-location>
</taglib>
</web-app>
1.3.3 JSP 引用方式
1.3.4運行示範
1.3.5 JSP 原文 <%@page contentType="text/html; charset=GBK"%>
<%@taglib uri="FCK" prefix="FCK"%>
<html>
<head>
<title>index</title>
</head>
<body bgcolor="#ffffff">
<form action="postdata.jsp" name="form1" method="POST">
文檔標題:<input type="text" name="test" value="測試資料" />
<FCK:editor id="EditorDefault" basePath="/FCKeditor/"
fontNames="宋體;Arial;Courier New;Times New Roman;Verdana"
imageBrowserURL="/FCKeditor/editor/filemanager/browser/default/browser.html?Type=Image&Connector=connectors/jsp/connector"
linkBrowserURL="/FCKeditor/editor/filemanager/browser/default/browser.html?Connector=connectors/jsp/connector"
flashBrowserURL="/FCKeditor/editor/filemanager/browser/default/browser.html?Type=Flash&Connector=connectors/jsp/connector"
imageUploadURL="/FCKeditor/editor/filemanager/upload/simpleuploader?Type=Image"
linkUploadURL="/FCKeditor/editor/filemanager/upload/simpleuploader?Type=File"
flashUploadURL="/FCKeditor/editor/filemanager/upload/simpleuploader?Type=Flash">
以下內容為 <strong>測試資料</strong>. 歡迎使用 <a href="http://www.fredck.com/fckeditor/">FCKeditor</a>.
</FCK:editor>
<input type="submit" value="提交"/>
</form>
</body>
</html>