茫茫網海中的冷日
         
茫茫網海中的冷日
發生過的事,不可能遺忘,只是想不起來而已!
 恭喜您是本站第 1675722 位訪客!  登入  | 註冊
主選單

Google 自訂搜尋

Goole 廣告

隨機相片
PIMG_00407.jpg

授權條款

使用者登入
使用者名稱:

密碼:


忘了密碼?

現在就註冊!

爪哇咖啡屋 : [轉貼]FCKeditor For Java/Jsp

發表者 討論內容
冷日
(冷日)
Webmaster
  • 註冊日: 2008/2/19
  • 來自:
  • 發表數: 15771
[轉貼]FCKeditor For Java/Jsp
FCKeditor For Java/Jsp

1.下載
FCKeditor.java 2.3/FCKeditor-2.3.zip (FCKeditor for java)
FCKeditor_2.3b.zip (FCKeditor基本文件)

2.建立項目:Project/FCKeditor

3.FCKeditor.java FCKeditor-2.3.zip解壓後,把其中的web目錄下的WEB-INF目錄copy到FCKeditor下(裡面有commons-fileupload.jar, FCKeditor-2.3.jar,web.xml等幾個文件), 把其中的src目錄下的FCKeditor.tld文件copy到FCKeitor/WEB-INF/下

4.修改web.xml:
把SimpleUploader中的配置屬性enabled定義為true(開啟文件上傳功能),加上editor所在目錄
 <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>

添加標籤定義:
<taglib>
<taglib-uri>/FCKeditor</taglib-uri>
<taglib-location>/WEB-INF/FCKeditor.tld</taglib-location>
</taglib>


5.解壓FCKeditor_2.3b.zip後,把目錄/editor和fckconfig.js, fckeditor.js, fckstyles.xml, fcktemplates.xml四個文件copy到/FCKeditor下
刪除目錄/editor/_source,
刪除/editor/filemanager/browser/default/connectors/下的除了test.html外的所有文件夾
刪除/editor/filemanager/upload/下除了test.html外的所有文件夾

6.打開/FCKeditor/fckconfig.js
修改
FCKConfig.DefaultLanguage = 'zh-cn' ;

把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' ;


7.三種方法調用FCKeditor
(1).FCKeditor自定義標籤 (必須加頭文件 <%@ taglib uri="/FCKeditor" prefix="FCK" %> )
顯示
<form action="show.jsp" method="post" target="_blank">
<FCK:editor id="content" basePath="/FCKeditor/" width="700" height="500" skinPath="/FCKeditor/editor/skins/silver/"
 toolbarSet = "Default" >
input
</FCK:editor>
<input type="submit" value="Submit">
</form>

(2).script腳本語言調用 (必須引用 腳本文件 )
顯示
<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 = "/FCKeditor/" ;
oFCKeditor.Height = 400;
oFCKeditor.ToolbarSet = "Default" ;
oFCKeditor.ReplaceTextarea();
</script>
<input type="submit" value="Submit">
</td></tr></table>
</form>

(3).FCKeditor API 調用 (必須加頭文件 <%@ page language="java" import="com.fredck.FCKeditor.*" %> )
<form action="show.jsp" method="post" target="_blank">
<%
FCKeditor oFCKeditor ;
oFCKeditor = new FCKeditor( request, "content" ) ;
oFCKeditor.setBasePath( "/FCKeditor/" ) ;
oFCKeditor.setValue( "input" );
out.println( oFCKeditor.create() ) ;
%>
<br>
<input type="submit" value="Submit">
</form>


8.輸出:
<%
String content = request.getParameter("content");
out.print(content);
%>


另:FCKeditor for Java的上傳是通過servlet進行的,不是Jsp,所以配置文件web.xml中的"editor/filemanager/browser/default/connectors/jsp/connector" jsp/connector 目錄並不存在,只要配置好FCKeditor.java就行了,最後上傳非常快

原文出處:FCKeditor For Java/Jsp 感冒
前一個主題 | 下一個主題 | | | |

討論串




Powered by XOOPS 2.0 © 2001-2008 The XOOPS Project|