FCKeditor简单使用实例(for jsp)

使用的版本:
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
[color=red]slf4j-simple-1.5.2.jar[/color]
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=/userUploadFile
connector.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">

//初始化fckeditor
window.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");
取值。

项目目录结构:
[img]/upload/attachment/67094/bd21214d-3675-39f5-ae48-9cdf9eb93bb6.jpg[/img]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值