FCKEditor 2.6 JSP 使用说明(嵌入方法)
FCKEditor 2.6 使用说明
(b本文只适用于2.6版本,请勿更改lib压缩包中的内容。
说明:fckeditor在进行文字编辑时,使用的仍是html标签,只是终端客户在编辑时见不到一系列标签而矣.它传往后台的字符串是添加了标签的字符串.
附件说明:
a:lib.rar, 2.6所需全部jar文件的压缩包;
b:fckeditor所需组件, 2.6的依赖js文件(官方原始版);
c:fckeditor-java-2.6-bin.zip,官方的支持java的压缩包,内附英文版详细说明,可以暂时不用.
)
1.导入以下jar包.(见附件中的"lib压缩包")
commons-collections-2.0.20020914.015953.jar
commons-fileupload-1.2.1.jar
commons-io-1.3.2.jar
fckeditor-java-core-2.6.jar
imageinfo-1.9.jar
slf4j-api-1.5.8.jar
slf4j-log4j12-1.5.2.jar
log4j-1.2.15.jar
2. 在web.xml中注册servlet.
<servlet>
<servlet-name>ConnectorServlet</servlet-name>
<servlet-class>net.fckeditor.connector.ConnectorServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>ConnectorServlet</servlet-name>
<!-- Do not wrap this line otherwise Glassfish will fail to load this file --> <!--可能对glassFish的支持比较好-->
<url-pattern>/fckeditor/editor/filemanager/connectors/*</url-pattern>
</servlet-mapping>
3. 将fckeditor文件夹复制到webRoot根目录下.(见附件中:"fckeditor所需组件.rar")
4.修改fckeditor的配置文件(fckeditor\fckconfig.js).
FCKConfig.LinkBrowserURL = FCKConfig.BasePath + "filemanager/browser/default/browser.html?Connector=connectors/jsp/connector" ;
FCKConfig.ImageBrowserURL = FCKConfig.BasePath + "filemanager/browser/default/browser.html?Type=Image&Connector=connectors/jsp/connector" ;
FCKConfig.FlashBrowserURL = FCKConfig.BasePath + "filemanager/browser/default/browser.html?Type=Flash&Connector=connectors/jsp/connector" ;
FCKConfig.LinkUploadURL = FCKConfig.BasePath + 'filemanager/upload/simpleuploader?Type=File' ;
FCKConfig.FlashUploadURL = FCKConfig.BasePath + 'filemanager/upload/simpleuploader?Type=Flash' ;
FCKConfig.ImageUploadURL = FCKConfig.BasePath + 'filemanager/upload/simpleuploader?Type=Image' ;
5.添加JSP页面.
<%@ taglib uri="http://java.fckeditor.net" prefix="FCK"%>
<form action="FckServlet" method="get" target="_blank">
<FCK:editor instanceName="EditorDefault">
<jsp:attribute name="value">This is some <strong>sample text</strong>.
You are using <a href="http://www.fckeditor.net">FCKeditor</a>.
</jsp:attribute>
</FCK:editor>
<input type="submit" value="Submit" />
</form>
6. 添加FckServlet 获取前台字符串。
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
Enumeration<String> params = (Enumeration<String>) request.getParameterNames();
String parameter;
while(params.hasMoreElements()) {
parameter = params.nextElement();
System.out.println(parameter);
System.out.println(request.getParameter(parameter));
}
request.getRequestDispatcher("sampleposteddata.jsp").forward(request, response);
}