日期:2014-05-16  浏览次数:20342 次

Jsp-FCKeditor_2.6.6安装步骤及配置说明
一、安装步骤

下面就来介绍一下以jsp为例FCKeditor_2.6.4的安装步骤

1、下载

      如果你使用的是jsp技术开发网站需要下载两个文件:网址:http://www.fckeditor.net/download               

      FCKeditor_2.6.6.zip,就是FCKEditor的控件;         
      FCKeditor.Java (fckeditor-java-2.6-bin.zip),就是在Java代码中使用FCKEditor的相关工具类;

2、安装

     FCKeditor_2.6.zip解压缩,找到一个叫fckeditor的文件夹,将其整个复制到你的web应用的根目录下。    
     将commons-fileupload-1.2.1.jar, commons-io-1.3.2.jar, fckeditor-java-core-2.6.jar,slf4j-api-1.5.6.jar,imageinfo-1.9.jar,slf4j-nop-1.5.2.jar这五个包拷贝到WEB-INFO/lib文件夹下。(fckeditor-java-2.4.1-bin.zip解压缩后,在其子文件夹下可找到前三个jar文件,后两个jar文件必须是同版本的,可是他只提供了一个,我们可以去slf4官方网站下载:http://www.slf4j.org/download.html )

3、配置

     (1)FCKeditor的配置相当简单,在你的web.xml中增加一个servlet即可
http://baidu.com
Java代码
<servlet>  
 
       <servlet-name>Connector</servlet-name>  
 
       <servlet-class>net.fckeditor.connector.ConnectorServlet</servlet-class>  
 
       <load-on-startup>1</load-on-startup>  
 
       </servlet>  
 
 
 
       <servlet-mapping>  
 
       <servlet-name>Connector</servlet-name>  
 
       <url-pattern>/fckeditor/editor/filemanager/connectors/*</url-pattern>  
 
       </servlet-mapping>  


如果你和我一样使用的struts2进行项目开发的话,你会发现当上传文件时会出现 “Error on file upload. Error number:203”的错误提示。这是因为fck与struts2框架不兼容,struts2转发了fck的servlet。
解决办法:在web.xml中修改struts2的filter-mapping

Java代码
<filter-mapping>  
 
       <filter-name>struts2</filter-name>  
 
       <url-pattern>*.action</url-pattern>  
 
       <url-pattern>*.jsp</url-pattern>  
 
</filter-mapping> 

如果还有其他url映射也可以添加到filter-mapping中去。

可是这样配置了struts2标签就不可以使用了,当你访问带有s标签的页面时控制台中提示:
引用
ERROR - Servlet.service() for servlet jsp threw exception
The Struts dispatcher cannot be found. This is usually caused by using Struts tags without the associated filter. Struts tags are only usable when the request has passed through its servlet filter, which initializes the Struts dispatcher needed for this tag. - [unknown location]


在网上找到一些答案,例如增加</filter-mapping>
Java代码
<filter-mapping>  
 
       <filter-name>struts2</filter-name>  
 
       <url-pattern>/struts/*</url-pattern>  
 
</filter-mapping>  
如果细心一点会发现,并不是所有的带s标签的页面都不能正常显示,凡是经*.action转发后的页面便可以使用s标签。凡是使用s标签的页面经*.action转发就可以了,虽然并不是根本的解决方法,但却很好的保护了项目路径。
(2)在项目开发目录的src下建立一个名为fckeditor.properties的文件,添加文件内容: connector.userActionImpl=net.fckeditor.requestcycle.impl.UserActionImpl 保存即可.

如果你没有做这一步,当你上传文件是出现提示:the current user isn't authorized for file browsing。
4、在jsp中使用FCKEditor控件
(1)在需要使用这个控件的j