ITPub博客

首页 > Linux操作系统 > Linux操作系统 > fckeditor_for_java的用法

fckeditor_for_java的用法

原创 Linux操作系统 作者:mystart2012 时间:2012-11-18 22:53:41 0 删除 编辑
在很多时候都需要使用网页编辑器,包括在文章发布的时候或是在表单设计的时候。下面为fckeditor的使用。
 
以javascript方法调用
 方法(一)
 将fckeditor.jar包拷贝到webroot目录下,新建一html文件,加如一下代码
 拷代码(在head内):
 
 在body内:
 
    var FCKeditor = new FCKeditor('FCKeditor');
    // http://localhost:8080/fckeditor
    // http://localhost:8080/test/fckeditor
    oFCKeditor.BasePath = "test/fckeditor/"; // test/是基路径,注意Basepath一定要以斜线结尾
    
     oFCKeditor.Width = "60";  //指定fckeditor的宽度
     oFCKeditor.Height = "400"; //指定fckeditor的高度
     oFCKeditor.Value = "initial value"; //指定fckeditor的初始值
     oFCKeditor.ToolBarSet = "Basic"; //指定fckeditor的工具集类型
     
    oFCKeditor.Create();
 
 
 方法(二)
 将fckeditor.jar包拷贝到webroot目录下,新建一html文件
   拷代码(在head内):
      //src中第一个fckeditor是项目名称
     
        window.onload = function(){
            var FCKeditor = new FCKeditor('MyTextarea');
            oFCKeditor.BasePath = "fckeditor/";
            oFCKeditor.ReplaceTextarea();
          }
     
     在body内加代码:
         
        
 *********************************       
 在jsp中通过自定义标签调用:
   可以参考:(根据最新版本来定)  
     1,演示工程fckeditor-java-demo-2.4.war
           不能直接查看已经发布后访问到的页面的源码,因为那是个jsp页面,看项目本身的js文档
     2,fckeditor-java-2.4的文档(解压fckeditor-java-bin.rar)
           1)新建jsp页面
           2)拷jar包:fckeditor-java-core.jar(核心jar包),lib下的两个文件上传的和日志的jar包
           3)写代码:
                <%@ taglib uri="http://java.fckeditor.net" prefix="FCK"%>
              在body内:
                  
              //basepath一定要以'/'开头,  '/'代表当前工程的路径
              //一定要设置value属性的值,并且值不能是空字符串 
            注:可能会出现缺少类的情况,比较方便的方法是看已提供的demo项目!!     
            
   *****************************
   配置文件(自定义配置):
      1,在fckeditor中有一个fckconfig.js文件,然后可以直接进行相应的修改,一般不采用这种方法,而是采用额外的文件
      2,在webroot下见一个myconfig.js文件,只需写需要修改的配置项(参考文档)
          FCKConfig.AutoDetectLanguage = false ;
       3,
          1>在fckeditor中自带的fckconfig.js文件中指定
             FCKConfig.CustomConfigurationsPath = '/test/myconfig.js';
          2>在页面代码中调用代码对FCKeditor的实例进行配置:
             body中的fckeditor中指定: oFCKeditor.Config["CustomConfigurationPath"] = '/test/myconfig.js';
       4,重新部署即可
 
以上为fckeditor的使用步骤,同时也可以用java代码的方式写成标签。

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/28225168/viewspace-749445/ ,如需转载,请注明出处,否则将追究法律责任。

下一篇: java实现验证码
请登录后发表评论 登录
全部评论

注册时间:2012-10-22

  • 博文量
    23
  • 访问量
    52009