一 FCKeditor的下载
先给出FCKeditor的下载页面 http://ckeditor.com/download
下载FCKeditor_2.6.6.zip fckeditor-java-2.6-bin.zip fckeditor-java-demo-2.6.war 这3个文件
分别解压后备用
二 将FCKeditor放入Web Project
- 将fckeditor拷贝,放置在WebRoot下
editor
fckconfig.js
fckeditor.js
fckpackager.xml
fckstyle.js
fcktemplates.xml
以上红色部分 为必要项,喜欢用javascript显示就需要用fckeditor.js
- 导入fckeditor所需要的相关jar包
fckeditor-java-core-2.6.jar
commons-fileupload.jaar
commons-io.jar
imageinfo.jar
slf4j-api.jar
slf4j.jar - 在src目录下新建fckeditor.properties配置文件,内容如下
connector.userActionImpl=net.fckeditor.requestcycle.impl.EnabledUserAction - 在web.xml文件中配置servlet
三 FCKeditor在页面上的使用
- 在<head>中引入 <script type="text/javascript" src="fckeditor/fckeditor.js"></script>
- 在body中需要使用fckeditor的地方加入
<script type="text/javascript">
var oFCKeditor = new FCKeditor('FCKeditor1');
oFCKeditor.BasePath="<%=request.getScheme()+ "://" +request.getServerName() + ":" + request.getServerPort() + request.getContextPath() + "/fckeditor/"%>";
oFCKeditor.Create();
</script>
四 FCKeditor配置
FCKeditor的相关配置文件都可以在fckconfig.js修改,也可以自定义文件修改.
本文中使用自定配置修改
在WebRoot下新建/js/myfckconfig.js文件,内容如下
更改页面
<SCRIPT type="text/javascript">
var oFCKeditor = new FCKeditor('content','100%','400px');
oFCKeditor.BasePath="<%=request.getScheme()+ "://" +request.getServerName() + ":" + request.getServerPort() + request.getContextPath() + "/fckeditor/"%>";
//指定自定义配置文件路径
oFCKeditor.Config["CustomConfigurationsPath"]="/FCK/js/myfckconfig.js";
//选择工具集
oFCKeditor.ToolbarSet="Custom";
oFCKeditor.Create();
</SCRIPT>