六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 127|回复: 0

FCKeditor学习与总结

[复制链接]

升级  45.33%

32

主题

32

主题

32

主题

秀才

Rank: 2

积分
118
 楼主| 发表于 2013-2-7 22:45:36 | 显示全部楼层 |阅读模式
怎么在java web程序中添加fckeditor?
 
 
1、下载 fckeditor for java包, 解压放到WebRoot下
 
2、新建html,内容如下:
     a) 注意导入fckeditor.js
     b) sBasePath 路径,这是加上了http://192.168.0.141:8012/Demo/的地址。
 
<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title></title><script type="text/javascript" src="../FCKeditor/fckeditor.js"></script><script type="text/javascript">var sBasePath = document.location.href.substring(0,document.location.href.lastIndexOf('yx'));function load(){ var fckobj = new FCKeditor('f_content');       //alert(sBasePath);              fckobj.BasePath = sBasePath +"FCKeditor/" ;         fckobj.Height = 300;         fckobj.Width = 530;         fckobj.ReplaceTextarea();}</script></head><body id="body" ><textarea id="f_content"></textarea></body></html> 
3、拷贝如下内容到web.xml中:
     a) 注意baseDir是上传文件地址
     b ) 拷贝fckeditor-java-core-2.4.1.jar、slf4j-api-1.5.2.jar、slf4j-simple-1.5.2.jar、commons-io-     1.3.2.jar、commons-fileupload-1.2.1.jar到classpath中
 
<!-- fckeditor upload servlet begin -->    <servlet>        <servlet-name>Connector</servlet-name>        <servlet-class>net.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-mapping>        <servlet-name>Connector</servlet-name><!-- Do not wrap this line otherwise Glassfish will fail to load this file -->        <url-pattern>/FCKeditor/editor/filemanager/connectors/*</url-pattern>    </servlet-mapping> 
4、文件目录解释:
 
该目录为FCKeditor的核心目录,包含了FCKeditor的核心文件,其中:(1)    _source为FCKEditor的源文件目录(2)    css为FCKeditor的样式文件目录(3)    dialog为FCKeditor工具栏中相应的工具按钮的弹出对话框文件目录(4)    filemanager为FCKeditor处理文件上传的文件目录(5)    images为FCKeditor中增加表情头像等资源的图像文件目录(6)    js为FCKeditor的核心javascript文件目录(7)    lang为FCKeditor的语言文件目录,包含国际化支持。(8)    plugins为FCKeditor的插件目录,FCKeditor的插件开发文件都放入该目录(9)    skins为FCKeditor的皮肤文件,自带三种皮肤文件default,office2003和silver。 
 5、拷贝fckeditor.properties到classpath下,实例内容为:
 
connector.userActionImpl=com.huitu.khms.util.UserActionImplconnector.resourceType.flash.extensions.allowed=swf|fla|mpg|asf|wma|wmv|avi|mov|mp3|rmvb|mid    UserActionImpl
package com.huitu.khms.util;import javax.servlet.http.HttpServletRequest;import net.fckeditor.requestcycle.UserAction;public class UserActionImpl implements UserAction {    public boolean isEnabledForFileBrowsing(HttpServletRequest req) {                return true;    }    public boolean isEnabledForFileUpload(HttpServletRequest req) {       return true;    }} 
ok了
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表