FCKeditor是sourceforge.net上面的一個開源項目,主要是實現線上網頁編輯器的功能,可以讓web程式擁有如MS Word這樣強大的編輯功能。官方網站為http://www.fckeditor.net ,在伺服器端支援ASP.Net、ASP、ClodFusion、PHP、Java等語言,並且支援IE 5+、Mozilla 、Netscape等主流瀏覽器。
首先在官方網站下載fckeditor,注意有兩個包,一個是主檔案,一個是jsp整合包的。
1、解壓FCKeditor_2.2.zip,(FCKeditor主檔案),將FCKeditor目錄複寫到網站根目錄下,
2、解壓FCKeditor-2.3.zip,(jsp,FCKeditor整合包),作用:This is the JSP Integration Pack for using FCKeditor inside a java server page without the complexity of using a Java scriptlets or the javascript api.
3、將FCKeditor-2.3/web/WEB-INF/web.xml中的兩個servlet,servlet-mapping定義複製到自已項目的web.xml檔案中
修改:
<servlet-mapping>
<servlet-name>Connector</servlet-name>
<url-pattern>
/editor/filemanager/browser/default/connectors/jsp/connector
</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>SimpleUploader</servlet-name>
<url-pattern>/editor/filemanager/upload/simpleuploader</url-pattern>
</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、將FCKeditor-2.3/web/WEB-INF/lib目錄下檔案複製到自已項目的lib檔案夾中
5、在需使用FCKeditor的jsp介面中加入:
// 檔案開頭處加入
<%@ taglib uri="http://fckeditor.net/tags-fckeditor" prefix="FCK" %>
//要使用的地方加入
<FCK:editor id="content" basePath="/FCKeditor/"
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">
this is default content :)
</FCK:editor>