Fck editor

JSP中FCKeditor在线编辑器的使用

在线编辑器对于我们作新闻产品之类的程序是很重要的,在网上找录了好了好一段时间,发现FCKeditor,跨平台的,正在进行的jsp项目正需要这款html在线编辑器。试用了一下FCKeditor,根据网上的文章小结一下:

1.下载

FCKeditor.java 2.3 (FCKeditot for java)

FCKeditor 2.4.3 (FCKeditor基本文件)

以下是下载地址:

http://sourceforge.net/projects/fckeditor/files/

2.建立项目:

建立项目fck.(开发工具Eclipse3.3 +MyEclipse5.1)

在WebRoot下新建夹UserFiles及子文件夹Image、Flash、File。

3.将FCKeditor2.4解压缩

将FCKeditor2.4解压缩,将整个目录FCKeditor复制到项目的根目录下,

目录结构为:WebRoot/FCKeditor(默认名称为fckeditor)

然后将FCKeditor-2.3.zip(java)压缩包中webWEB-INFlib目录下的两个jar文件拷到项目的WEB-INF/lib目录下。把其中的src目录下的FCKeditor.tld文件copy到WebRoot/WEB-INF/下

4.合并web.xml:

将FCKeditor-2.3.zip压缩包中webWEB-INF目录下的web.xml文件合并到项目的WEB-INF目录下的web.xml文件中。

注:默认为web-app_2_2.dtd,最好在新Web.xml把主体内容复制进来即可。

5. 修改合并后的web.xml文件

修改合并后的web.xml文件,将名为SimpleUploader的Servlet的enabled参数值改为true,

以允许上传功能,Connector Servlet的baseDir参数值与设置上传文件存放的位置一致(/UserFiles/)。

 

运行图:

6. 映射:

上面文件中两个servlet的映射分别为:/editor/filemanager/browser/default/connectors/jsp/connector

和/editor/filemanager/upload/simpleuploader,需要在两个映射前面加上/FCKeditor,

即改为/FCKeditor/editor/filemanager/browser/default/connectors/jsp/connector和

/FCKeditor/editor/filemanager/upload/simpleuploader。

7.修改skin文件夹

进入skin文件夹,如果你想使用fckeditor默认的这种奶黄色,

那就把除了default文件夹外的另两个文件夹直接删除.

8.删除无用文件

删除/FCKeditor/目录下除fckconfig.js, fckeditor.js, fckstyles.xml, fcktemplates.xml四个文件以外的所有文件

删除目录/editor/_source,

删除/editor/filemanager/browser/default/connectors/下的所有文件

删除/editor/filemanager/upload/下的所有文件

删除/editor/lang/下的除了 en.js, zh.js, zh-cn.js三个文件的所有文件


9.修改配置:

打开/FCKeditor/fckconfig.js

修改 FCKConfig.DefaultLanguage = 'zh-cn' ;

把FCKConfig.LinkBrowserURL等的值替换成以下内容:

FCKConfig.LinkBrowserURL= FCKConfig.BasePath +"filemanager/browser/default/browser.html?Connector=connectors/jsp/connector" ;

FCKConfig.ImageBrowserURL= FCKConfig.BasePath + "filemanager/browser/default/browser.html?Type=Image&Connector=connectors/jsp/connector" ;

FCKConfig.FlashBrowserURL= FCKConfig.BasePath + "filemanager/browser/default/browser.html?Type=Flash&Connector=connectors/jsp/connector" ;

FCKConfig.LinkUploadURL = FCKConfig.BasePath + 'filemanager/upload/simpleuploader?Type=File' ;

FCKConfig.FlashUploadURL = FCKConfig.BasePath + 'filemanager/upload/simpleuploader?Type=Flash' ;

FCKConfig.ImageUploadURL = FCKConfig.BasePath + 'filemanager/upload/simpleuploader?Type=Image' ;

(注:千万不要一股脑替换了,因为中间还有其他的属性配置)

10.其它

fckconfig.js总配置文件,可用记录本打开,修改后将文件存为utf-8 编码格式。找到:

FCKConfig.TabSpaces = 0 ; 改为FCKConfig.TabSpaces = 1 ; 即在编辑器域内可以使用Tab键。

 

如果你的编辑器还用在网站前台的话,比如说用于留言本或是日记回复时,那就不得不考虑安全了,

在前台千万不要使用Default的toolbar,要么自定义一下功能,要么就用系统已经定义好的Basic,

也就是基本的toolbar,找到:

FCKConfig.ToolbarSets["Basic"] = [['Bold','Italic','-','OrderedList','UnorderedList','-',/*'Link',*/'Unlink','-','Style','FontSize','TextColor','BGColor','-','Smiley','SpecialChar','Replace','Preview'] ] ;

这是改过的Basic,把图像功能去掉,把添加链接功能去掉,因为图像和链接和flash和图像按钮添加功能都能让前台

页直接访问和上传文件, fckeditor还支持编辑域内的鼠标右键功能。

 

FCKConfig.ContextMenu = ['Generic',/*'Link',*/'Anchor',/*'Image',*/'Flash','Select','Textarea','Checkbox','Radio','TextField','HiddenField',

/*'ImageButton',*/'Button','BulletedList','NumberedList','TableCell','Table','Form'] ;

这也是改过的把鼠标右键的“链接、图像,FLASH,图像按钮”功能都去掉。

  找到: FCKConfig.FontNames = 'Arial;Comic Sans MS;Courier New;Tahoma;Times New Roman;Verdana' ;

加上几种我们常用的字体

FCKConfig.FontNames= '宋体;黑体;隶书;楷体_GB2312;Arial;Comic Sans MS;Courier New;Tahoma;Times New Roman;Verdana' ;

 


页面测试 :

复制_samples的jsp文件夹到WebRoot下,

 

 

例一: sample01.jsp

<%@ page language="java" import="com.fredck.FCKeditor.*" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>

<head>

<title>FCKeditor - JSP Sample</title>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<meta name="robots" content="noindex, nofollow">

<link href="../sample.css" rel="stylesheet" type="text/css" />

<script type="text/javascript">

function FCKeditor_OnComplete( editorInstance )

{

window.status = editorInstance.Description ;

}

</script>

</head>

<body>

<h1>FCKeditor - JSP - Sample 1</h1>

This sample displays a normal HTML form with an FCKeditor with full features

enabled.

<hr>

<form action="sampleposteddata.jsp" method="get" target="_blank">

<%

FCKeditor oFCKeditor ;

oFCKeditor = new FCKeditor( request, "EditorDefault" ) ;

oFCKeditor.setBasePath( "/FCKeditor/" ) ;

oFCKeditor.setValue( "This is some <strong>sample text</strong>. You are using <a href=/"http://www.fredck.com/fckeditor//">FCKeditor</a>." );

out.println( oFCKeditor.create() ) ;

%>

<br>

<input type="submit" value="Submit">

</form>

</body>

</html>

 

更改oFCKeditor.setBasePath( "/FCKeditor/" ) ;为oFCKeditor.setBasePath( "/fck/FCKeditor/" ) ;


启动http://localhost:8080/fck

注:fck为本测试工程的名称,可根据需要自行更改

 

其他限制:

本地上传图片、Flash和文件名不支持中文

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值