1.下载FCKeditor_2.6.4.zip,http://downloads.sourceforge.net/project/fckeditor/FCKeditor/2.6.4/FCKeditor_2.6.4.zip?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Ffckeditor%2Ffiles%2FFCKeditor%2F2.6.4%2F&ts=1292413994&use_mirror=cdnetworks-kr-1及相关的java的一个项目demo:fckeditor-java-demo-2.6.war,http://downloads.sourceforge.net/project/fckeditor/FCKeditor.Java/2.6/fckeditor-java-demo-2.6.war?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Ffckeditor%2Ffiles%2FFCKeditor.Java%2F2.6%2F&ts=1292413946&use_mirror=cdnetworks-kr-1
,其实就一个demo就可以了,我是按demo来的。

2,解压fckeditor-java-demo-2.6.war,看里面的东西不多说了,把web.xml里面内容复制到你的项目web.xml里面,还有lib下面的jar包放到项目里面,及classes目录下面的fckeditor.properties放到src目录下,fckeditor目录放到webroot下面。

3,好了,在你的jsp里面直接创建fckeditor对象

  

 
  
  1. <
  2.  //创建fckeditor对象,参数request对象,还有inputname 
  3.   FCKeditor fckeditor = new FCKeditor(request,"content");  
  4. //默认的工具栏太多了东西,自己建了一个Demo 
  5. fckeditor.setToolbarSet("Demo"); 
  6. fckeditor.setWidth("601px"); 
  7. fckeditor.setHeight("371px"); 
  8.  
  9. %> 

     自己有选择的定义ToolbarSet;修改fckeditor下的fckconfig.js,添加下面内容:

  

 
  
  1. FCKConfig.ToolbarSets["Demo"] = [ 
  2.     ['Bold','Italic','-','OrderedList','UnorderedList','-','Link','Unlink','-','About'], 
  3.     ['Image','Flash','Table','Rule','Smiley','SpecialChar','PageBreak'], 
  4.     ['TextColor','BGColor'], 
  5. ] ; 

4.在需要的地方直接out.println(fckeditor);

 

 
  
  1. <%out.print(fckeditor); %> 

5,如果这样整合struts2时上传图片会出现错误,因为配置的strut拦截器拦截/*,把fckeditor也给拦了,并且在一连串的chain中有些东西丢了,这时呢有两种办法,一种把web.xml里面struts拦截的url   /*改为只拦截*.action以及.jsp,这种方法行得通,不过如果咱们整合spring的话action交给spring时咱们可以不用.action那么麻烦,这时就必须让struts拦截/*了,这时有第二种办法解决,及重建一个struts拦截器,当拦截到是fckeditor时直接不用再往下面的chain传了,直接返回就行。

     <1>新建一类例如:FckeditorFilter,然后让它继承StrutsPrepareAndExecuteFilter 并且重写doFilter方法.

        

 
  
  1. @Override 
  2. public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { 
  3.     HttpServletRequest request = (HttpServletRequest) req; 
  4.     if ("/fckeditor/editor/filemanager/connectors".equals(request.getServletPath())){ 
  5.         chain.doFilter(req, res); 
  6.     }else{ 
  7.         super.doFilter(req, res, chain); 
  8.     } 

  <2>更改web.xml里面的struts拦截器类为咱们上面新建的就可以了。

6,用js得到fckeditor的内容,代码如下。

 

 
  
  1. function getText(){ 
  2.      
  3.      var oEditor = FCKeditorAPI.GetInstance('content'); //content 为fckeditor的名称 
  4.      var content = oEditor.GetXHTML(true);  
  5.      return content;}