一 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>