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
  slf4j-simple-1.5.2.jar
  fckeditor-java-core-2.4.jar

2. 将fckeditor放到WebRoot目录中

3. web.xml文件中添加
Xml代码 复制代码  收藏代码
  1. <!-- FCKeditor配置 -->    
  2. <servlet>  
  3.     <servlet-name>Connector</servlet-name>  
  4.     <servlet-class>net.fckeditor.connector.ConnectorServlet</servlet-class>  
  5.     <load-on-startup>1</load-on-startup>  
  6. </servlet>  
  7. <servlet-mapping>  
  8.     <servlet-name>Connector</servlet-name>  
  9.     <url-pattern>/fckeditor/editor/filemanager/connectors/*</url-pattern>  
  10. </servlet-mapping>  
  11. <!-- FCKeditor配置 -->   


4. 在src中新建fckeditor.properties文件:
Properties代码 复制代码  收藏代码
  1. #Fckeditor setting   
  2. #用户上传文件路径目录   
  3. connector.userFilesPath=/userUploadFile   
  4. connector.userActionImpl=net.fckeditor.requestcycle.impl.UserActionImpl  


5. jsp页面:
Html代码 复制代码  收藏代码
  1. <%@ page contentType="text/html;charset=utf-8" %>  
  2. <%@ page import="java.util.*" %>  
  3. <%   
  4. String path = request.getContextPath();   
  5. String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path;   
  6. %>  
  7. <link href="<%=basePath %>/fckeditor/_samples/sample.css" rel="stylesheet" type="text/css" />  
  8. <script type="text/javascript" src="<%=basePath %>/fckeditor/fckeditor.js"></script>  
  9. <script type="text/javascript">  
  10.   
  11. //初始化fckeditor   
  12. window.onload = function()   
  13. {   
  14.     var sBasePath = "<%=basePath %>/fckeditor/";   
  15.     var oFCKeditor = new FCKeditor( 'content' ) ;   
  16.     oFCKeditor.BasePath = sBasePath ;   
  17.     oFCKeditor.ReplaceTextarea() ;   
  18. }   
  19. </script>  
  20. <html>  
  21.   <head>  
  22.     <title>fckeditor_demo</title>  
  23.   </head>  
  24.   <body>  
  25.   <form action="showdata.jsp" method="post">  
  26.    <textarea   name="content" rows="10" cols="80" style="width: 100%; height: 200px" ></textarea>  
  27.    <br>  
  28.     <input type="submit" value="提交"/>  
  29.    </form>  
  30.   </body>  
  31. </html>  
<%@ 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. 提交后,后台取值通过
Java代码 复制代码  收藏代码
  1. String data = request.getParameter("content");  
String data = request.getParameter("content");
取值。

项目目录结构:
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值