Fckeditor控件請到官方網站下載http://wwwfckeditornet本例主要用到FCKeditor_zipfckeditorjavademozipfckeditorjavabinzip裡面的一些內容讀者可以自行下載
解開壓縮包FCKeditor_zip將其中的fckeditor文件夾復制到WEBINF下面後面可以直接使用
在頁面中使用FCKeditor有兩種方式
方式一JavaScript的方式
()直接使用見methodhtml
<!DOCTYPE HTML PUBLIC
//W
C//DTD HTML
Transitional//EN
>
<html>
<head>
<script type=
text/javascript
src=
fckeditor/fckeditor
js
></script>
</head>
<body>
方法一通過JavaScript來實現的實現編輯器導入<br>
<script type=
text/javascript
>
var oFCKeditor = new FCKeditor(
FCKeditor
) ;
oFCKeditor
BasePath =
fckeditor/
;
//oFCKeditor
BasePath =
/FCKEditTest/fckeditor/
;
oFCKeditor
Width=
%
;
oFCKeditor
Height=
;
oFCKeditor
Value=
initial value
;
//oFCKeditor
ToolbarSet=
Basic
;
//默認是default
oFCKeditor
ToolbarSet=
Default
;
oFCKeditor
Create() ;
</script>
<hr>
</body>
</html>
()通過Textarea祥見methodhtml
<!DOCTYPE HTML PUBLIC
//W
C//DTD HTML
Transitional//EN
>
<html>
<head>
<script type=
text/javascript
src=
fckeditor/fckeditor
js
></script>
<script type=
text/javascript
>
window
onload=function(){
var oFCKeditor = new FCKeditor(
MyTextarea
) ;
oFCKeditor
BasePath =
fckeditor/
;
//oFCKeditor
BasePath =
/FCKEditTest/fckeditor/
;
oFCKeditor
ReplaceTextarea();
}
</script>
</head>
<body>
方法二通過Textarea來實現的實現編輯器導入<br>
<textarea rows=
cols=
name=
MyTextarea
>this is a value</textarea>
</body>
</html>
方式二在標簽使用FCKeditor
在使用標簽之前需要搭建環境將fckeditorjavabinzip包中的fckeditorjavacorejarcommonsfileuploadjarcommonsiojarslfjapijar以及包fckeditorjavademozip中的slfjsimplejar復制到lib目錄下並構建環境
構建完後就可以在JSP頁面中進行使用祥見頁面method_jspjsp
<%@ page language=
java
import=
java
util
*
pageEncoding=
utf
%>
<%@ taglib uri=
http://java
fckeditor
net
prefix=
FCK
%>
<!DOCTYPE HTML PUBLIC
//W
C//DTD HTML
Transitional//EN
>
<html>
<head>
<title>method_jsp
jsp</title>
</head>
<body>
早些版本必需將fckeditor的Value屬性必需指定對應的值且值不能為空 而此處版本是該問題已經解決
<FCK:editor instanceName=
myEditor
basePath=
/fckeditor
></FCK:editor>
</body>
</html>
效果如下圖
From:http://tw.wingwit.com/Article/program/Java/JSP/201311/20742.html