创建JS版的FCKeditor(无法实现上传功能,但可以实现表单验证,适合于发表评论):
1,创建jsp页面jsEditor.jsp代码如下:
在头部添加:<script type="text/javascript" src="FCKeditor/fckeditor.js"></script>
在正文部分:
<form action="show.jsp" method="get">
<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>
2,JAVA版FCKeditor(可以实现上传,但无法实现表单验证,适合于编写文章)
1,相关配置
1)准备工作
将fckeditor文件夹放于WebRoot目录下;
将以下三个包: commons-fileupload.jar, FCKeditor-2.3.jar,xalan.jar放于lib目录下(如果没有xalan.jar包则不能浏览服务器中的文件);
将FCKeditor.tld文件拷到web-inf文件夹下面;
将准备好的web.xml文件覆盖web-inf下的web.xml文件(注意先建好类在做这一步);
2)建立相关类
在src目录下建立包:cm.fredck.FCKeditor.connector, cm.fredck.FCKeditor.tags,
cm.fredck.FCKeditor.uploader
在cm.fredck.FCKeditor.connector包下建立一个名为ConnectorServlet的Servlet,虚拟路径就是ConnectorServlet;
在cm.fredck.FCKeditor.tags包下建立一个名为FCKeditorTag的java类;
在cm.fredck.FCKeditor.uploader包下建立一个名为SimpleUploaderServlet的servlet,虚拟路径就是SimpleUploaderServlet;
2,调用fckeditor
通过以上的配置后,fckeditor基本上可以用了;
1. FCKeditor自定义标签 (必须加头文件 <%@ taglib uri="/WEB-INF/FCKeditor.tld" prefix="fck" %>
代码如下:
<FORM action=" " target="blank">
<fck:editor id="testfck" basePath="/项目名/fckeditor/"
height="500"
width="800"
skinPath="/项目名/fckeditor/editor/skins/office2003/"
toolbarSet="Default"
imageBrowserURL="/项目名/fckeditor/editor/filemanager/browser/default/browser.HTML?Type=Image&Connector=connectors/jsp/connector" linkBrowserURL="/项目名/fckeditor/editor/filemanager/browser/default/browser.html?Connector=connectors/jsp/connector"
flashBrowserURL="/项目名/fckeditor/editor/filemanager/browser/default/browser.html?Type=Flash&Connector=connectors/jsp/connector"
imageUploadURL="/项目名/fckeditor/editor/filemanager/upload/simpleuploader?Type=Image" linkUploadURL="/项目名/fckeditor/editor/filemanager/upload/simpleuploader?Type=File" flashUploadURL="/项目名/fckeditor/editor/filemanager/upload/simpleuploader?Type=Flash">
</fck:editor>
<br>
<input type="submit" value="确定">
</FORM>
注:需要FCKeditor皮肤的请用QQ联系。