六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 75|回复: 0

FCKeditor简单使用实例(for jsp)

[复制链接]

升级  72%

8

主题

8

主题

8

主题

童生

Rank: 1

积分
36
 楼主| 发表于 2013-1-29 07:41:58 | 显示全部楼层 |阅读模式
使用的版本:
   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");取值。

项目目录结构:
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表