HTML编辑器FCKeditor使用详解

作者:FastUnit 来源:Java快速开发平台 时间:2010-02-28 12:30:00 

本文介绍FCKeditor在Java环境下的使用方法。

一、简介

功能:所见即所得,支持图片和Flash,工具栏可自由配置,使用简单
兼容性:IE 5.5+、Firefox 1.5+、Safari 3.0+、Opera 9.50+、Netscape 7.1+、 Camino 1.0+
成熟度:使用广泛,被Baidu、CSDN等选用

二、下载

官方下载首页:http://www.fckeditor.net/download/,当前版本为2.5.1
需要下载FCKeditor 2.5.1(FCKeditor_2.5.1.zip)和FCKeditor.Java(FCKeditor-2.3.zip

三、部署

本例以WebRoot作为应用根路径,部署后的目录结构如下图所示:


1、FCKeditor_2.5.1.zip解压,将fckeditor文件夹复制到/WebRoot/下

2、FCKeditor-2.3.zip解压,将commons-fileupload.jar和FCKeditor-2.3.jar复制到/WebRoot/WEB-INF/lib/下 

3、修改/WebRoot/WEB-INF/web.xml文件,增加以下内容:             

<servlet>
<servlet-name>Connector</servlet-name>
        <servlet-class>com.fredck.FCKeditor.connector.ConnectorServlet</servlet-class>
        <init-param>
            <param-name>baseDir</param-name>
            <param-value>/UserFiles/</param-value>
        </init-param>
        <init-param>
            <param-name>debug</param-name>
            <param-value>true</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet>
        <servlet-name>SimpleUploader</servlet-name>
        <servlet-class>com.fredck.FCKeditor.uploader.SimpleUploaderServlet</servlet-class>
        <init-param>
            <param-name>baseDir</param-name>
            <param-value>/UserFiles/</param-value>
        </init-param>
        <init-param>
            <param-name>debug</param-name>
            <param-value>true</param-value>
        </init-param>
        <init-param>
            <param-name>enabled</param-name>
            <param-value>true</param-value>
        </init-param>
        <init-param>
            <param-name>AllowedExtensionsFile</param-name>
            <param-value></param-value>
        </init-param>
        <init-param>
            <param-name>DeniedExtensionsFile</param-name>
            <param-value>php|php3|php5|phtml|asp|aspx|ascx|jsp|cfm|cfc|pl|bat|exe|dll|reg|cgi</param-value>
        </init-param>
        <init-param>
            <param-name>AllowedExtensionsImage</param-name>
            <param-value>jpg|gif|jpeg|png|bmp</param-value>
        </init-param>
        <init-param>
            <param-name>DeniedExtensionsImage</param-name>
            <param-value></param-value>
        </init-param>
        <init-param>
            <param-name>AllowedExtensionsFlash</param-name>
            <param-value>swf|fla</param-value>
        </init-param>
        <init-param>
            <param-name>DeniedExtensionsFlash</param-name>
            <param-value></param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>

  <servlet-mapping>
    <servlet-name>Connector</servlet-name>
    <url-pattern>/fckeditor/connector</url-pattern>
  </servlet-mapping>
  
  <servlet-mapping>
    <servlet-name>SimpleUploader</servlet-name>
    <url-pattern>/fckeditor/simpleuploader</url-pattern>
  </servlet-mapping>

 4、修改/WebRoot/fckeditor/fckconfig.js,修改部分如下:

FCKConfig.LinkBrowserURL = FCKConfig.BasePath + 'filemanager/browser/default/browser.html?Connector=/fckeditor/connector' ;
FCKConfig.ImageBrowserURL = FCKConfig.BasePath + 'filemanager/browser/default/browser.html?Type=Image&Connector=/fckeditor/connector' ;
FCKConfig.FlashBrowserURL = FCKConfig.BasePath + 'filemanager/browser/default/browser.html?Type=Flash&Connector=/fckeditor/connector' ;
FCKConfig.LinkUploadURL = '/fckeditor/simpleuploader?Type=File' ;
FCKConfig.ImageUploadURL = '/fckeditor/simpleuploader?Type=Image' ;
FCKConfig.FlashUploadURL = '/fckeditor/simpleuploader?Type=Flash';

注意
(1) 步骤3、4设置了文件浏览和上传的配置,web.xml中Servlet的<url-pattern>要和fckconfig.js中的URL引用一致;
(2) 本例正常运行的前提是WebRoot被部署为根路径,如果设了虚拟路径会找不到servlet。

标签:FCKeditor,编辑器,html编辑器
0
投稿

猜你喜欢

  • Python获取当前时间日期的实现示例

    2021-12-26 04:43:21
  • mysql日志文件General_log和Binlog开启及详解

    2024-01-17 08:20:44
  • 详解OpenCV中简单的鼠标事件处理

    2023-01-04 12:16:01
  • 最新整理Python中的type和object的示例详解

    2023-08-10 05:21:44
  • 浅谈图像处理中掩膜(mask)的意义

    2021-03-17 01:48:50
  • 4个场景教会你Go中Goroutine和通道是怎么用的

    2024-04-23 09:45:05
  • Python实现定时备份mysql数据库并把备份数据库邮件发送

    2024-01-18 09:48:04
  • Python 类的魔法属性用法实例分析

    2022-02-20 07:22:15
  • 如何让用户再次访问我的网站时不需再提交相关信息?

    2010-05-16 15:05:00
  • python文件操作之目录遍历实例分析

    2021-05-16 11:46:16
  • 使用DIV+CSS设计网页的好处

    2007-10-14 15:02:00
  • php asp.net 比较 [推荐]

    2024-04-29 13:57:51
  • js星级评分代码

    2008-05-02 21:07:00
  • python 爬取影视网站下载链接

    2022-07-30 00:59:42
  • Python pandas对excel的操作实现示例

    2023-09-25 18:24:13
  • python中adb有什么功能

    2022-06-22 13:25:15
  • python基于socket函数实现端口扫描

    2022-02-06 09:22:37
  • java之File对象对文件的操作常用的几个方法(推荐)

    2024-01-14 13:13:27
  • Python中的图像处理之Python图像平滑操作

    2021-06-05 12:56:06
  • 神经网络训练采用gpu设置的方式

    2021-04-24 16:43:25
  • asp之家 网络编程 m.aspxhome.com