1、导入相应jar包
2、将fredck.FCKeditor的包放置到对应目录下(src下的cn.itcast)
3、将fckeditor的文件夹复制到WEBRoot下
4、使用FCK的标签,将FCKeditor.tld的标签放置到WEB-INF下
同时修改标签中的内容,要在src的路径下找到该路径:<tag>
<name>editor</name>
<tagclass>cn.itcast.fredck.FCKeditor.tags.FCKeditorTag</tagclass>
<bodycontent>JSP</bodycontent>
<attribute>
<name>id</name>
<required>true</required>
</attribute>
5、在web.xml中添加:路径要正确
<!--liu add FCK文本编辑器start-->
<servlet>
<servlet-name>Connector</servlet-name>
<servlet-class>cn.itcast.fredck.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>
<servlet-name>SimpleUploader</servlet-name>
<servlet-class>cn.itcast.fredck.FCKeditor.uploader.SimpleUploaderServlet</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>
<init-param>
<param-name>enabled</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>AllowedExtensionsFile</param-name>
<param-value></param-value>
</init-param>
<init-param>
<param-name>DeniedExtensionsFile</param-name>
<param-value>php|php3|php5|phtml|asp|aspx|ascx|jsp|cfm|cfc|pl|bat|exe|dll|reg|cgi</param-value>
</init-param>
<init-param>
<param-name>AllowedExtensionsImage</param-name>
<param-value>jpg|gif|jpeg|png|bmp</param-value>
</init-param>
<init-param>
<param-name>DeniedExtensionsImage</param-name>
<param-value></param-value>
</init-param>
<init-param>
<param-name>AllowedExtensionsFlash</param-name>
<param-value>swf|fla</param-value>
</init-param>
<init-param>
<param-name>DeniedExtensionsFlash</param-name>
<param-value></param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<!-- end -->
<!-- liu add FCK文本编辑器 start -->
<servlet-mapping>
<servlet-name>Connector</servlet-name>
<url-pattern>/fckeditor/editor/filemanager/browser/default/connectors/jsp/connector</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>SimpleUploader</servlet-name>
<url-pattern>/fckeditor/editor/filemanager/upload/simpleuploader</url-pattern>
</servlet-mapping>
<!-- end -->
6、修改actingIndex.jsp,将站点运行情况和设备运行情况改成FCK文本编辑器
(1)添加FCK的标签库
<%@ taglib uri="/WEB-INF/FCKeditor.tld" prefix="FCK"%>
(2)添加:
<FCK:editorid="stationRun" basePath="${pageContext.request.contextPath }/fckeditor/"height="300"
toolbarSet="Basic"
imageBrowserURL="${pageContext.request.contextPath}/fckeditor/editor/filemanager/browser/default/browser.html?Type=Image&Connector=connectors/jsp/connector"
linkBrowserURL="${pageContext.request.contextPath}/fckeditor/editor/filemanager/browser/default/browser.html?Connector=connectors/jsp/connector">
</FCK:editor>
<FCK:editorid="devRun" basePath="${pageContext.request.contextPath }/fckeditor/"height="300"
toolbarSet="Basic"
imageBrowserURL="${pageContext.request.contextPath}/fckeditor/editor/filemanager/browser/default/browser.html?Type=Image&Connector=connectors/jsp/connector"
linkBrowserURL="${pageContext.request.contextPath}/fckeditor/editor/filemanager/browser/default/browser.html?Connector=connectors/jsp/connector">
</FCK:editor>
上传图片时弹出Error on file upload.Error number:203如附件 error.jpg的错误
原因:fck的servlet被struts2转发了
解决:在web.xml中修改filter-mapping 将
<filter>
<filter-name>struts2</filter-name>
<filter-class> org.apache.struts2.dispatcher.FilterDispatcher </filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern
</filter-mapping>
修改成
<filter>
<filter-name>struts2</filter-name>
<filter-class> org.apache.struts2.dispatcher.FilterDispatcher </filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>*.do</url-pattern>
<url-pattern>*.jsp</url-pattern>
</filter-mapping>