溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

JSP如何使用FCKeditor

發(fā)布時間:2021-11-03 14:01:35 來源:億速云 閱讀:115 作者:小新 欄目:編程語言

小編給大家分享一下JSP如何使用FCKeditor,希望大家閱讀完這篇文章之后都有所收獲,下面讓我們一起去探討吧!

FCKeditor是sourceforge.net上面的一個開源項目,主要是實現(xiàn)在線網(wǎng)頁編輯器的功能,可以讓web程序擁有如MS Word這樣強大的編輯功能。官方網(wǎng)站為http://www.fckeditor.net,在服務器端支持ASP.Net、ASP、ClodFusion、PHP、Java等語言,并且支持IE 5+、Mozilla 、Netscape等主流瀏覽器。

首先在官方網(wǎng)站下載Fckeditor,注意有兩個包,一個是主文件,一個是JSP整合包的。

1、解壓FCKeditor_2.2.zip,(FCKeditor主文件),將FCKeditor目錄復制到網(wǎng)站根目錄下,

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>

  1. <servlet-mapping>   

  2. <servlet-name>Connector</servlet-name>   

  3. <url-pattern>/FCKeditor/editor/filemanager/browser/default/connectors/jsp/connector
    </url-pattern>   

  4. </servlet-mapping>   

  5.  

  6. <servlet-mapping>   

  7. <servlet-name>SimpleUploader</servlet-name>   

  8. <url-pattern>/FCKeditor/editor/filemanager/upload/simpleuploader</url-pattern> 

  9. </servlet-mapping>  

4、將FCKeditor-2.3/web/WEB-INF/lib目錄下文件復制到自已項目的lib文件夾中

5、在需JSP使用FCKeditor的界面中加入:

  1. // 文件開頭處加入   

  2. <%@ taglib uri="http://fckeditor.net/tags-fckeditor" prefix="FCK" %>   

  3. //要使用的地方加入   

  4. <FCK:editor id="content" basePath="/FCKeditor/"   

  5. imageBrowserURL="/FCKeditor/editor/filemanager/browser/default/browser.html?
    Type=Image&Connector=connectors/jsp/connector"
       

  6. linkBrowserURL="/FCKeditor/editor/filemanager/browser/default/browser.html?
    Connector=connectors/jsp/connector"
       

  7. flashBrowserURL="/FCKeditor/editor/filemanager/browser/default/browser.html?
    Type=Flash&Connector=connectors/jsp/connector"
       

  8. imageUploadURL="/FCKeditor/editor/filemanager/upload/simpleuploader?Type=Image"   

  9. linkUploadURL="/FCKeditor/editor/filemanager/upload/simpleuploader?Type=File"   

  10. flashUploadURL="/FCKeditor/editor/filemanager/upload/simpleuploader?Type=Flash">   

  11. this is default content :)   

  12. </FCK:editor>  

啟動服務器測試。。。。成功后,來給FCKeditor瘦瘦身.
1.將FCKeditor目錄下及子目錄下所有以”_”下劃線開頭的文件夾刪除
2.FCKeditor根目錄下只保留fckconfig.js, fckeditor.js, fckstyles.xml, fcktemplates.xml其余全部刪除
3.將editor/filemanager/upload目錄下文件及文件夾清空.
4.還可以將editor/skins目錄下的皮膚文件刪除,只留下default一套皮膚(如果你不需要換皮膚的話)
5.還可以將editor/lang目錄下文件刪除,只保留en.js, fcklanguagemanager.js, zh-cn.js, zh.js文件(英文,簡體中文,繁體中文一般應該夠用了:) )

完成,現(xiàn)在看是不是清爽了很多?

其它問題:

在struts+spring+hibernate中使用,上傳圖像功能中可能會出現(xiàn)報:The output format must have a '{http://xml.apache.org/xalan}content-handler' property!錯的情況,將WEB-INF/lib目錄下xalan*.jar刪除試試

安全問題:

假如在前臺讓普通用戶也能JSP使用FCKeditor,要注意相關安全問題,在前臺使用時,不要使用默認的ToolBar,
要將添加圖像,flash,圖像域按鈕去掉
在fckconfig.js中大約78行配置  那些數(shù)組中的值就像當于界面上的一個功能,你可以強行把每組值試出來代表什么。

看完了這篇文章,相信你對“JSP如何使用FCKeditor”有了一定的了解,如果想了解更多相關知識,歡迎關注億速云行業(yè)資訊頻道,感謝各位的閱讀!

向AI問一下細節(jié)

免責聲明:本站發(fā)布的內容(圖片、視頻和文字)以原創(chuàng)、轉載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權內容。

AI