|
|
使用的版本:
FCKeditor_2.6.3
fckeditor-java-2.4-bin
1. 新建一WEB项目,将一下jar包放到lib中:
commons-fileupload-1.2.1.jar
commons-io-1.3.2.jar
slf4j-api-1.5.2.jar
slf4j-simple-1.5.2.jar
fckeditor-java-core-2.4.jar
2. 将fckeditor放到WebRoot目录中
3. web.xml文件中添加
<!-- FCKeditor配置 --> <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> <!-- FCKeditor配置 -->
4. 在src中新建fckeditor.properties文件:
#Fckeditor setting#用户上传文件路径目录connector.userFilesPath=/userUploadFileconnector.userActionImpl=net.fckeditor.requestcycle.impl.UserActionImpl
5. jsp页面:
<%@ page contentType="text/html;charset=utf-8" %><%@ page import="java.util.*" %><%String path = request.getContextPath();String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path;%><link href="<%=basePath %>/fckeditor/_samples/sample.css" rel="stylesheet" type="text/css" /><script type="text/javascript" src="<%=basePath %>/fckeditor/fckeditor.js"></script><script type="text/javascript">//初始化fckeditorwindow.onload = function(){var sBasePath = "<%=basePath %>/fckeditor/";var oFCKeditor = new FCKeditor( 'content' ) ;oFCKeditor.BasePath= sBasePath ;oFCKeditor.ReplaceTextarea() ;}</script><html> <head> <title>fckeditor_demo</title> </head> <body> <form action="showdata.jsp" method="post"> <textarea name="content" rows="10" cols="80" style="width: 100%; height: 200px" ></textarea> <br> <input type="submit" value="提交"/> </form> </body></html>
6. 提交后,后台取值通过
String data = request.getParameter("content");取值。
项目目录结构:
 |
|