JSP下FCKeditor的安裝
下載地址:http://www.fckeditor.net/download
?????????接下來我們可以開始配置了。
我是在eclipse下來配置的
環(huán)境:
jdk:1.4
eclisp:3.12
plugin:myeclipse4.0
FCKeditor :FCKeditor_2.3.2
FCKeditor.java:FCKeditor-2.3
1.新建一個webproject,我這里取名為FCK。
2.把FCKeditor_2.3.2目錄下的FCKeditor目錄拷貝到FCK工程的根目錄,即WebRoot目錄下。
3.將FCKeditor-2.3\web\WEB-INF目錄下的web.xml中的兩個servlet,servlet-mapping定義復(fù)制到工程的web.xml文件中去。
4.修改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>
這里的/FCKeditor/是對應(yīng)你webroot目錄下的FCKeditor目錄。
5.拷貝FCKeditor-2.3\web\WEB-INF\lib下的兩個jar包到WebRoot\WEB-INF\lib目錄下
(在項(xiàng)目的庫中添加FCKeditor-2.3\web\WEB-INF\lib下的兩個jar包? 達(dá)不到同樣的效果,一定要拷貝到lib目錄下)
6.在webroot目錄下新建一個jsp,使用默認(rèn)的MyJsp.jsp即可。
7. 文件開頭處加入? :
<%@ taglib uri="
8.在jsp中嵌入的代碼:在Jsp中使用
方法一:(可能會出現(xiàn):The requested resource (/FCK/editor/fckeditor.html) is not available)
<c:set var="basepath"><c:url value="/fck/" /></c:set>
<FCK:editor id="descn" basePath="${basepath}" height="500px">
<c:out value="${book.descn}" escapeXml="false" default="" />
</FCK:editor>
方法二:
<FCK:editor id="infoContent" basePath="/FCK/FCKeditor/"
????????????? width="800"
????????????? height="300"?????????????????????????
????????????? >
????????????? 請輸入內(nèi)容
</FCK:editor>
9.部署好工程,開啟tomcat,打開MyJsp.jsp頁面即可。
10.三種方法調(diào)用FCKeditor
<%--
三種方法調(diào)用FCKeditor
1.FCKeditor自定義標(biāo)簽 (必須加頭文件 <%@ taglib uri="/TestFCKeditor" prefix="FCK" %> )
2.script腳本語言調(diào)用 (必須引用 腳本文件 <script type="text/javascript" src="/TestFCKeditor/FCKeditor/fckeditor.js"></script> )
3.FCKeditor API 調(diào)用 (必須加頭文件 <%@ page language="java" import="com.fredck.FCKeditor.*" %> )
--%>
<%--
<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>
--%>
<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>
<%--
<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);
out.println(request.getParameter("title"));
%>
<!--表單中的input的name可以等于這里request.getParameter("parameter") 中的parameter參數(shù)。可以通過out.println輸出
<FCK:editor id="content".....>FCK中的id相當(dāng)于input的name
-->
11.FCKeditor編輯器文件上傳配置
FCKeditor編輯器的配置文件是fckconfig.js,其中有對編輯器各種默認(rèn)屬性的設(shè)置。以下是fckeditor與java集成使用 時上傳文件的設(shè)置(需要注意的是編輯器不會自動創(chuàng)建文件上傳的文件夾,需要在項(xiàng)目的根目錄中手動添加),將fckeditor.js文件中以下幾個屬性原 來的值修改為如下設(shè)置:
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' ;
至此,即可使用FCKeditor的文件上傳功能。
posted on 2006-11-10 12:42 小雨不打傘 閱讀(2222) 評論(2) 編輯 收藏 所屬分類: web學(xué)習(xí)心得