FCKeditor JSP版本安装手顺

FCKeditor JSP版本安装手顺

 

FCKeditor在线编辑器的使用(jsp:html在线编辑器=FCKeditor 2.2+FCKeditor.java 2.3 )

 

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

1.
下载
FCKeditor.java 2.3 (FCKeditot for java)
FCKeditor 2.2 (FCKeditor
基本文件)
以下是下载地址:

http://www.fckeditor.net/download/default.html

2.
建立项目:
建立项目tomcat/webapps/TestFCKeditor.

3.
FCKeditor2.2解压缩
FCKeditor2.2解压缩,将整个目录FCKeditor复制到项目的根目录下,
目录结构为:tomcat/webapps/TestFCKeditor/FCKeditor
然后将FCKeditor-2.3.zipjava)压缩包中/web/WEB-INF/lib/目录下的两个jar文件拷到项目的/WEB-INF/lib/目录下。把其中的src目录下的FCKeditor.tld文件copyTestFCKedit/WEB-INF/


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


5.
修改合并后的web.xml文件
修改合并后的web.xml文件,将名为SimpleUploaderServletenabled参数值改为true
以允许上传功能,Connector ServletbaseDir参数值用于设置上传文件存放的位置。
添加标签定义:
<taglib>
<taglib-uri>/TestFCKeditor</taglib-uri>
<taglib-location>/WEB-INF/FCKeditor.tld</taglib-location>
</taglib>

运行图:



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/下的除了fcklanguagemanager.js, 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' ;

11.添加文件
添加文件 /TestFCKeditor/test.jsp:
<%@ page language="java" import="com.fredck.FCKeditor.*" %>
<%@ taglib uri="/TestFCKeditor" prefix="FCK" %>
<script type="text/javascript" src="/TestFCKeditor/FCKeditor/fckeditor.js"></script>

<%--
三种方法调用FCKeditor
1.FCKeditor自定义标签 (必须加头文件 <%@ taglib uri="/TestFCKeditor" prefix="FCK" %> )
2.script脚本语言调用 (必须引用 脚本文件 <script type="text/javascript" src="/TestFCKeditor/FCKeditor/fckeditor.js"></script> )
3.FCKeditor API 调用 (必须加头文件 <%@ page language="java" import="com.fredck.FCKeditor.*" %> )
--%>

<%--
<form action="show.jsp" method="post" target="_blank">
<FCK:editor id="content" basePath="/TestFCKeditor/FCKeditor/"
width="700"
height="500"
skinPath="/TestFCKeditor/FCKeditor/editor/skins/silver/"
toolbarSet = "Default"
>
input
</FCK:editor>
<input type="submit" value="Submit">
</form>
--%>

<form action="show.jsp" method="post" target="_blank">
<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 = "/TestFCKeditor/FCKeditor/" ;
oFCKeditor.Height = 400;
oFCKeditor.ToolbarSet = "Default" ;
oFCKeditor.ReplaceTextarea();
</script>
<input type="submit" value="Submit">
</td></tr></table>
</form>

<%--
<form action="show.jsp" method="post" target="_blank">
<%
FCKeditor oFCKeditor ;
oFCKeditor = new FCKeditor( request, "content" ) ;
oFCKeditor.setBasePath( "/TestFCKeditor/FCKeditor/" ) ;
oFCKeditor.setValue( "input" );
out.println( oFCKeditor.create() ) ;
%>
<br>
<input type="submit" value="Submit">
</form>
--%>

添加文件/TestFCKeditor/show.jsp:
<%
String content = request.getParameter("content");
out.print(content);
%>

12.测试
浏览http://localhost:8080/TestFCKeditor/test.jsp
ok!

 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
彻底解决fckeditor(jsp版)上传中文图片乱码问题,我这里用的编码是utf-8的,这里用的fckeditor 是2.6的,fckeditor.java包是2.3的,经过我修改ConnectorServlet.java和SimpleUploaderServlet.java两个文件,重新生成fckeditor-java-2.3.jar包, 要解决所有的乱码问题,有3部要修改, 1.修改Web容器的字符编码,如果Web容器用的是Tomcat,则修改conf/server.xml文件,在两个Connector中添加“URIEncoding="utf-8"”,我这里用的是utf-8编码,所以修改成utf-8,若项目是gb2312编码,则设置为“URIEncoding="gb2312"”。 2.在“浏览服务器”页面中上传文件时,打开项目WebRoot中的文件/editor/filemanager/browser/default/frmupload.html,在head中加一个meta: <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />,看看该文件是不是utf-8格式的,若不是,则转换成utf-8,若你用的不是utf-8则转成你用的那种编码,上面charset也设置成你用的编码 3.修改ConnectorServlet.java和SimpleUploaderServlet.java两个文件,我在这两个文件中都是加了一个静态变量encoding,private static String encoding;保存项目中的编码, 若在web.xml文件中没有给这个变量传值的话,默认是gb2312,如下代码if(encoding.isEmpty()){encoding="gb2312";},在ConnectorServlet.java的doGet与doPost的开头部分加入request.setCharacterEncoding(encoding);将请求的字符集编码设置成项目中的编码,在ConnectorServlet.java和SimpleUploaderServlet.java两个文件中的DiskFileUpload upload = new DiskFileUpload();后面加入upload.setHeaderEncoding(encoding);告诉FileUpload组件处理时的编码为项目编码,在FileItem中,用getString(encoding),这项设置可以解决获取的表单字段为乱码的问题,所以在每个FileItem实例后面都执行一次getString(encoding),就告诉FileItem在取值时用的编码是encoding所设置的编码。如在ConnectorServlet.java和SimpleUploaderServlet.java两个文件中的 FileItem item后面加上一句item.getString(encoding);在FileItem uplFile后面加上一句uplFile.getString(encoding); 接下来就是设置web.xml了,在web.xml中给上面讲到的encoding传值,如下 <init-param> <param-name>encoding</param-name> <param-value>utf-8</param-value> </init-param> 一切都OK了,真正的解决了上传中文名图片乱码问题。 在上面的第3步中,要用到Ant产生jar,这时要注意, 把Tomcat安装目录下/server/lib里的catalina-ant.jar复制到项目的/WEB-INF/lib下。打开build.xml,修改property name="catalina.home"成Tomcat的安装目录。修改taskdef name="deploy"、taskdef name="list"、taskdef name="reload"、taskdef name="undeploy"如下: <taskdef name="deploy" classname="org.apache.catalina.ant.DeployTask"> <classpath refid="compile.classpath"></classpath> </taskdef> <taskdef name="list" classname="org.apache.catalina.ant.ListTask"> <classpath refid="compile.classpath"></classpath> </taskdef> <taskdef name="reload" classname="org.apache.catalina.ant.ReloadTask"> <classpath refid="compile.classpath"></classpath> </taskdef> <taskdef name="undeploy" classname="org.apache.catalina.ant.UndeployTask"> <classpath refid="compile.classpath"></classpath> </taskdef> 然后在Eclipse的Outline窗口中运行Ant的dist,就会生成的新的FCKeditor-2.3.jar。 绝对是真实的,共享出来与大家分享,少一个上传其它文件的,如RAR的,有添加过这个功能的朋友也拿出来共享下吧
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值