6. 映射:
上面文件中兩個(gè)servlet的映射分別為:/editor/filemanager/browser/default/connectors/jsp/connector
和/editor/filemanager/upload/simpleuploader,需要在兩個(gè)映射前面加上/FCKeditor,
即改為/FCKeditor/editor/filemanager/browser/default/connectors/jsp/connector和
/FCKeditor/editor/filemanager/upload/simpleuploader。
這兩個(gè)名字根據(jù)你放在工程中的FCKeditor文件夾名稱而定。。
7.修改skin文件夾
進(jìn)入skin文件夾,如果你想使用fckeditor默認(rèn)的這種奶黃色,
那就把除了default文件夾外的另兩個(gè)文件夾直接刪除.(建議不刪除,以后要用到其中的一個(gè)文件夾)
8.刪除無用文件
刪除/FCKeditor/目錄下除fckconfig.js, fckeditor.js, fckstyles.xml, fcktemplates.xml四個(gè)文件以外的所有文件,保留文件夾editor
刪除目錄/editor/_source,
刪除/editor/filemanager/browser/default/connectors/下的所有文件
刪除/editor/filemanager/upload/下的所有文件
刪除/editor/lang/下的除了fcklanguagemanager.js(我下載的沒有這個(gè)文件), en.js, zh.js, zh-cn.js四個(gè)文件的所有文件
9.修改配置:
打開/FCKeditor/fckconfig.js
修改 FCKConfig.DefaultLanguage = 'zh-cn' ;
把FCKConfig.LinkBrowserURL等的值替換成以下內(nèi)容:
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.FlashUploadURL = FCKConfig.BasePath + 'filemanager/upload/simpleuploader?Type=Flash' ;
FCKConfig.ImageUploadURL = FCKConfig.BasePath + 'filemanager/upload/simpleuploader?Type=Image' ;
10.其它
fckconfig.js總配置文件,可用記錄本打開,修改后將文件存為utf-8 編碼格式。找到:
FCKConfig.TabSpaces = 0 ; 改為FCKConfig.TabSpaces = 1 ; 即在編輯器域內(nèi)可以使用Tab鍵。
如果你的編輯器還用在網(wǎng)站前臺(tái)的話,比如說用于留言本或是日記回復(fù)時(shí),那就不得不考慮安全了,
在前臺(tái)千萬不要使用Default的toolbar,要么自定義一下功能,要么就用系統(tǒng)已經(jīng)定義好的Basic,
也就是基本的toolbar,找到:
FCKConfig.ToolbarSets["Basic"] = [
['Bold','Italic','-','OrderedList','UnorderedList','-',/*'Link',*/'Unlink','-','Style','FontSize','TextColor','BGColor','-',
'Smiley','SpecialChar','Replace','Preview'] ] ;
這是改過的Basic,把圖像功能去掉,把添加鏈接功能去掉,因?yàn)閳D像和鏈接和flash和圖像按鈕添加功能都能讓前臺(tái)
頁(yè)直接訪問和上傳文件, fckeditor還支持編輯域內(nèi)的鼠標(biāo)右鍵功能。
FCKConfig.ContextMenu = ['Generic',/*'Link',*/'Anchor',/*'Image',*/'Flash','Select','Textarea','Checkbox','Radio','TextField','HiddenField',
/*'ImageButton',*/'Button','BulletedList','NumberedList','TableCell','Table','Form'] ;
這也是改過的把鼠標(biāo)右鍵的“鏈接、圖像,F(xiàn)LASH,圖像按鈕”功能都去掉。
找到: FCKConfig.FontNames = 'Arial;Comic Sans MS;Courier New;Tahoma;Times New Roman;Verdana' ;
加上幾種我們常用的字體
FCKConfig.FontNames
= '宋體;黑體;隸書;楷體_GB2312;Arial;Comic Sans MS;Courier New;Tahoma;Times New Roman;Verdana' ;
11.添加文件
添加文件 /TestFCKeditor/test.jsp:
<%@ page language="java" import="com.fredck.FCKeditor.*" %>
<%@ taglib uri="/TestFCKeditor" prefix="FCK" %>
<script type="text/javascript" src="/TestFCKeditor/FCKeditor/fckeditor.js"></script>
<%--
三種方法調(diào)用FCKeditor
1.FCKeditor自定義標(biāo)簽 (必須加頭文件 <%@ taglib uri="/TestFCKeditor" prefix="FCK" %> )
2.script腳本語(yǔ)言調(diào)用 (必須引用 腳本文件 <script type="text/javascript" src="/TestFCKeditor/FCKeditor/fckeditor.js"></script> )
3.FCKeditor API 調(diào)用 (必須加頭文件 <%@ page language="java" import="com.fredck.FCKeditor.*" %> )
--%>
//標(biāo)簽調(diào)用方式
<%--
<form action="show.jsp" method="post" target="_blank">
<FCK:editor id="content" basePath="/TestFCKeditor/FCKeditor/"
width="700"
height="500"
skinPath="/TestFCKeditor/FCKeditor/editor/skins/silver/"
toolbarSet = "Default"
>
input
</FCK:editor>
<input type="submit" value="Submit">
</form>
--%>
//JS調(diào)用方式
<form action="show.jsp" method="post" target="_blank">
<table border="0" width="700"><tr><td>
<textarea id="content" name="content" style="WIDTH: 100%; HEIGHT: 400px">input</textarea>
<script type="text/javascript">
var oFCKeditor = new FCKeditor('content') ;
oFCKeditor.BasePath = "/TestFCKeditor/FCKeditor/" ;
oFCKeditor.Height = 400;
oFCKeditor.ToolbarSet = "Default" ;
oFCKeditor.ReplaceTextarea();
</script>
<input type="submit" value="Submit">
</td></tr></table>
</form>
//FCKeditor API 調(diào)用
<%--
<form action="show.jsp" method="post" target="_blank">
<%
FCKeditor oFCKeditor ;
oFCKeditor = new FCKeditor( request, "content" ) ;
oFCKeditor.setBasePath( "/TestFCKeditor/FCKeditor/" ) ;
oFCKeditor.setValue( "input" );
out.println( oFCKeditor.create() ) ;
%>
<br>
<input type="submit" value="Submit">
</form>
--%>
添加文件/TestFCKeditor/show.jsp:
<%
String content = request.getParameter("content");
out.print(content);
%>
12.測(cè)試
瀏覽http://localhost:8080/TestFCKeditor/test.jsp
最后注意。。不同的版本 變量名稱可能不一樣。請(qǐng)參考你使用的API文檔
配置選項(xiàng):
AutoDetectLanguage=true/false 自動(dòng)檢測(cè)語(yǔ)言
BaseHref="" 相對(duì)鏈接的基地址
ContentLangDirection="ltr/rtl" 默認(rèn)文字方向
ContextMenu=字符串?dāng)?shù)組,右鍵菜單的內(nèi)容
CustomConfigurationsPath="" 自定義配置文件路徑和名稱
Debug=true/false 是否開啟調(diào)試功能,這樣,當(dāng)調(diào)用FCKDebug.Output()時(shí),會(huì)在調(diào)試窗中輸出內(nèi)容
DefaultLanguage="" 缺省語(yǔ)言
EditorAreaCss="" 編輯區(qū)的樣式表文件
EnableSourceXHTML=true/false 為TRUE時(shí),當(dāng)由可視化界面切換到代碼頁(yè)時(shí),把HTML處理成XHTML
EnableXHTML=true/false 是否允許使用XHTML取代HTML
FillEmptyBlocks=true/false 使用這個(gè)功能,可以將空的塊級(jí)元素用空格來替代
FontColors="" 設(shè)置顯示顏色拾取器時(shí)文字顏色列表
FontFormats="" 設(shè)置顯示在文字格式列表中的命名
FontNames="" 字體列表中的字體名
FontSizes="" 字體大小中的字號(hào)列表
ForcePasteAsPlainText=true/false 強(qiáng)制粘貼為純文本
ForceSimpleAmpersand=true/false 是否不把&符號(hào)轉(zhuǎn)換為XML實(shí)體
FormatIndentator="" 當(dāng)在源碼格式下縮進(jìn)代碼使用的字符
FormatOutput=true/false 當(dāng)輸出內(nèi)容時(shí)是否自動(dòng)格式化代碼
FormatSource=true/false 在切換到代碼視圖時(shí)是否自動(dòng)格式化代碼
FullPage=true/false 是否允許編輯整個(gè)HTML文件,還是僅允許編輯BODY間的內(nèi)容
GeckoUseSPAN=true/false 是否允許SPAN標(biāo)記代替B,I,U標(biāo)記
IeSpellDownloadUrl=""下載拼寫檢查器的網(wǎng)址
ImageBrowser=true/false 是否允許瀏覽服務(wù)器功能
ImageBrowserURL="" 瀏覽服務(wù)器時(shí)運(yùn)行的URL
ImageBrowserWindowHeight="" 圖像瀏覽器窗口高度
ImageBrowserWindowWidth="" 圖像瀏覽器窗口寬度
LinkBrowser=true/false 是否允許在插入鏈接時(shí)瀏覽服務(wù)器
LinkBrowserURL="" 插入鏈接時(shí)瀏覽服務(wù)器的URL
LinkBrowserWindowHeight=""鏈接目標(biāo)瀏覽器窗口高度
LinkBrowserWindowWidth=""鏈接目標(biāo)瀏覽器窗口寬度
Plugins=object 注冊(cè)插件
PluginsPath="" 插件文件夾
ShowBorders=true/false 合并邊框
SkinPath="" 皮膚文件夾位置
SmileyColumns=12 圖符窗列數(shù)
SmileyImages=字符數(shù)組 圖符窗中圖片文件名數(shù)組
SmileyPath="" 圖符文件夾路徑
SmileyWindowHeight 圖符窗口高度
SmileyWindowWidth 圖符窗口寬度
SpellChecker="ieSpell/Spellerpages" 設(shè)置拼寫檢查器
StartupFocus=true/false 開啟時(shí)FOCUS到編輯器
StylesXmlPath="" 設(shè)置定義CSS樣式列表的XML文件的位置
TabSpaces=4 TAB鍵產(chǎn)生的空格字符數(shù)
ToolBarCanCollapse=true/false 是否允許展開/折疊工具欄
ToolbarSets=object 允許使用TOOLBAR集合
ToolbarStartExpanded=true/false 開啟是TOOLBAR是否展開
UseBROnCarriageReturn=true/false 當(dāng)回車時(shí)是產(chǎn)生BR標(biāo)記還是P或者DIV標(biāo)記
解決上傳亂碼:
在SimpleUploaderServlet.java和ConnectorServlet.java兩個(gè)文件里找到
DiskFileUpload upload = new DiskFileUpload();
分別在其后加入 upload.setHeaderEncoding("utf-8");
這樣解決了文件上傳的中文亂碼問題.
但是在控制臺(tái)顯示的中文內(nèi)容還是亂碼,但是沒關(guān)系,我們沒必要去看控制臺(tái)下的中文
----------------------------------------------------------------another
FCKeditor2.4.2 Java版使用說明
下載地址以及基本配置請(qǐng)參考:http://hi.baidu.com/wain19/blog/item/c33fb0fab74f24dfb48f312d.html
我的開發(fā)環(huán)境是ubuntu7.04, 系統(tǒng)默認(rèn)編碼是utf-8,
期間,本人遇到了下面這些問題:
問題一:XML request error: Internel Server Error(500)
出現(xiàn)錯(cuò)誤的地方是在:點(diǎn)插入圖片,點(diǎn)Browse按鈕的時(shí)候:
XML request error: Internel Server Error(500)
找資料:http://lamono.javaeye.com/blog/49135
拷貝xalan.jar和serialize.jar到/WEB-INF/lib,問題解決。
FCKeditor-java沒有很好的解決中文問題。需要我們修改它的源代碼后重新編譯打包。打包過程如下:
1。 新建一個(gè)web工程名字為FCKeditor-java-2.3,然后把FCKeditor-2.3-java.zip解壓縮后的代碼拷貝到工程目錄下。
2。如果是用的Eclipse,使用快捷鍵Ctrl+Shift+R
在SimpleUploaderServlet.java和ConnectorServlet.java兩個(gè)文件里找到
DiskFileUpload upload = new DiskFileUpload();
分別在其后加入 upload.setHeaderEncoding("utf-8");
現(xiàn)在如果直接運(yùn)行ant任務(wù),會(huì)報(bào)下面的錯(cuò)誤:
taskdef class org.apache.catalina.ant.DeployTask cannot be found
3。 把tomcat安裝目錄下/server/lib中的catalina-ant.jar拷貝到/WEB-INF/lib目錄 下。
4。 打開build.xml
找到
<property name="catalina.home"
修改成你自己的tomcat安裝目錄
<property name="catalina.home" value="/home/uniquejava/tool/tomcat5028/"/>
找到
<taskdef name="deploy"
修改成如下內(nèi)容
<taskdef name="deploy" classname="org.apache.catalina.ant.DeployTask">
<classpath refid="compile.classpath">
</classpath>
</taskdef>
<taskdef name="list" classname="org.apache.catalina.ant.ListTask">
<classpath refid="compile.classpath">
</classpath>
</taskdef>
<taskdef name="reload" classname="org.apache.catalina.ant.ReloadTask">
<classpath refid="compile.classpath">
</classpath>
</taskdef>
<taskdef name="undeploy" classname="org.apache.catalina.ant.UndeployTask">
<classpath refid="compile.classpath">
</classpath>
</taskdef>
運(yùn)行ant任務(wù)dist, 就可以生成新的FCKeditor-2.3.jar包
問題三: 上傳時(shí)新建的中文目錄全部亂碼。 雖然上傳到服務(wù)器上的文件名正常,但在JSP頁(yè)面點(diǎn)下載鏈接時(shí)文件名亂碼導(dǎo)致不能正常下載。
查找資料:TOMCAT 鏈接參數(shù)有中文時(shí),亂碼解決方法
<Connector port="8080"
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" redirectPort="8443" acceptCount="100"
debug="0" connectionTimeout="20000"
disableUploadTimeout="true" URIEncoding="utf-8" />
<Connector port="8009"
enableLookups="false" redirectPort="8443" debug="0"
protocol="AJP/1.3" URIEncoding="utf-8" />
方法二:
使用useBodyEncodingForURI="true". 這個(gè)方法適合你的TOMCAT實(shí)例下需要跑多個(gè)不同Encoding的程序時(shí)。(有點(diǎn)懷疑?!)
<... maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" redirectPort="8443" acceptCount="100"
connectionTimeout="20000" disableUploadTimeout="true" useBodyEncodingForURI="true" />
enableLookups="false" redirectPort="8443" protocol="AJP/1.3" useBodyEncodingForURI="true" /
我只試了方法一,問題解決!
這樣, FCKeditor終于可以正常使用了。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。
=================================================================
以下為個(gè)人原創(chuàng) http://blog.csdn.net/nickshen3/
怎么將FCKeditor2.4使用在自己的web中。
1. 在webapps創(chuàng)建test文件夾。webapps\test
2. 將下載的FCKeditor2.3的Java包FCKeditor-2.3.zip解壓縮,并將web文件夾下的兩個(gè)文件夾_samples,WEB-INF拷貝到剛才建立的webapps\test下。再將src文件夾下的FCKeditor.tld拷貝到WEB-INF下。
3. 在webapps\test\下建立文件夾FCKeditor 。
4. 將剛才下載的 FCKeditor_2.4.3.zip 解壓縮,然后將fckeditor文件夾下的 editor(文件夾),fckconfig.js,fckeditor.js,fckstyles.xml,fcktemplates.xml。四個(gè)文件拷貝到剛才建立的文件夾FCKeditor下。
5.修改test\_samples\jsp\sample02.jsp文件,將原來的
<FCK:editor id="EditorDefault" basePath="/FCKeditor/"
改為<FCK:editor id="EditorDefault" basePath="/test/FCKeditor/"。以后使用的時(shí)候只需將test換成項(xiàng)目的名稱即可。
6.打開tomcat。測(cè)試Http://localhost:8080/test/_samples/jsp/sample02.jsp。
ok。
另外 : http://www.tkk7.com/youxia/archive/2007/03/15/104077.html