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/fckeditorjs></script>
</head>
<body>
方法一通过JavaScript来实现的实现编辑器导入<br>
<script type=
text/javascript
>
var oFCKeditor = new FCKeditor(FCKeditor) ;
oFCKeditorBasePath = fckeditor/;
//oFCKeditorBasePath = /FCKEditTest/fckeditor/;
oFCKeditorWidth=%;
oFCKeditorHeight=;
oFCKeditorValue=initial value;
//oFCKeditorToolbarSet=Basic;
//默认是default
oFCKeditorToolbarSet=Default;
oFCKeditorCreate() ;
</script>
<hr>
</body>
</html>
()通过Textarea祥见methodhtml
<!DOCTYPE HTML PUBLIC
//W
C//DTD HTML
Transitional//EN
>
<html>
<head>
<script type=text/javascript src=fckeditor/fckeditorjs></script>
<script type=text/javascript>
windowonload=function(){
var oFCKeditor = new FCKeditor(MyTextarea) ;
oFCKeditorBasePath = fckeditor/;
//oFCKeditorBasePath = /FCKEditTest/fckeditor/;
oFCKeditorReplaceTextarea();
}
</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://javafckeditornet prefix=FCK%>
<!DOCTYPE HTML PUBLIC //WC//DTD HTML Transitional//EN>
<html>
<head>
<title>method_jspjsp</title>
</head>
<body>
早些版本必需将fckeditor的Value属性必需指定对应的值且值不能为空而此处版本是该问题已经解决
<FCK:editor instanceName=
myEditor
basePath=
/fckeditor
></FCK:editor>
</body>
</html>
效果如下图