ITeye博客

FckEditor for java 2.4的JSP 配置方法详解

netli · 2010-06-24 10:42 · j2se · 编程语言 · Markdown

FckEditor for java 2.4的JSP 配置方法详解

关键字: fckeditor for java

文章转自:http://hi.baidu.com/huqiwen/blog/item/7d36b15113fddd1e377abe7d.html
==============
由于FckEditor for java 2.4相对于2.3而言做了许多改变,这些改变使得我们的Fckeditor配置起来更方便。例如:
基础包名从:com.fredck.FCKeditor 改为 net.fckeditor.
文件上传SimpleUploaderServle整合到了ConnectorServlet里面,WEB,XML的配置就简单多了,下面通过一个实例说明配置详细步骤:

1、首先登陆www.fckeditor.net/download下载FCKeditor的最新版本,需要下载2个压缩包,一个是基本应用。另一个是在为在jsp下所准备的配置。
最新版本为:FckEditor2.6.3和FckEditor for java 2.4
FCKeditor 2.6.3下载地址:sourceforge.net/project/downloading.php     
       具体下载地址:http://easynews.dl.sourceforge.net/sourceforge/fckeditor/FCKeditor_2.6.3.zip
FCKeditor for Java 下载地址:sourceforge.net/project/downloading.php
具体下载地址:http://switch.dl.sourceforge.net/sourceforge/fckeditor/fckeditor-java-2.4.1-bin.zip(发行版,如果需要源码或者demo包请另行下载)
请下载demo包,否则会出现留言中那位朋友的错误!
下载之后分别为:FCKeditor_2.6.3.zip 和 fckeditor-java-2.4.1-bin.zip(fckeditor-java-demo-2.4.1.war)将它们分别解压。

2、首先在MyEclipse(或者其他的IDE)下建立一个新项目例如:fckeditDemo即http://localhost:8080/fckeditDemo
现在将解压后的FCKeditor_2.6.3.zip 里面的fckeditor文件夹拷贝到当前的项目文件夹里面。
引入fckeditor的六个包:

我的fckeditor项目目录结构如下:

3、配置web.xml。配置文件如下,这就是全部了,其他的不需要再配置,由于SimpleUploaderServle整合到了ConnectorServlet里面,所以文件上传等都不需要再配置。

Web.xml代码 复制代码

  1. <servlet>
  2. <servlet-name>Connector</servlet-name>
  3. <servlet-class>
  4. net.fckeditor.connector.ConnectorServlet
  5. </servlet-class>
  6. <load-on-startup>1</load-on-startup>
  7. </servlet>
  8. <servlet-mapping>
  9. <servlet-name>Connector</servlet-name>
  10. <url-pattern>
  11. /fckeditor/editor/filemanager/connectors/*
  12. </url-pattern>
  13. </servlet-mapping>
<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>

4、在src目录下面建立fckeditor.properties资源文件,在里面写入这么一行connector.userActionImpl=net.fckeditor.requestcycle.impl.UserActionImpl

5、下面写测试页面:

Index.jsp代码 复制代码

  1. <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
  2. <%@ taglib uri="http://java.fckeditor.net" prefix="FCK" %>
  3. <html>
  4. <head>
  5. <title>FckEditor测试</title>
  6. </head>
  7. <body style="text-align: center;">
  8. <div style="text-align: center;width: 600pt">
  9. <h2>FckEditor测试</h2>
  10. <hr>
  11. <form action="ShowData.jsp" method="post">
  12. <FCK:editor instanceName="test" height="400pt">
  13. <jsp:attribute name="value"> 这里是<a href="http://hi.baidu.com/huqiwen">数据测试</a>
  14. </jsp:attribute>
  15. </FCK:editor>
  16. <input type="submit" value="提交"/>
  17. <input type="reset" value="重置"/>
  18. </form>
  19. </div>
  20. </body>
  21. </html>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.fckeditor.net" prefix="FCK" %>
<html>
<head>    
    <title>FckEditor测试</title>
</head>
<body style="text-align: center;">
<div style="text-align: center;width: 600pt">
<h2>FckEditor测试</h2>
<hr>
<form action="ShowData.jsp" method="post">
     <FCK:editor instanceName="test" height="400pt">
   <jsp:attribute name="value"> 这里是<a href="http://hi.baidu.com/huqiwen">数据测试</a>
   </jsp:attribute>
</FCK:editor>      
   <input type="submit" value="提交"/>
   <input type="reset" value="重置"/>
   </form>
</div>
</body>
</html>

显示数据的页面:

Showdata.jsp代码 复制代码

  1. <%@ page language="java" contentType="text/html; charset=UTF-8"
  2. pageEncoding="UTF-8"%>
  3. <head>
  4. <title>FCKeditor - 显示数据</title>
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  6. </head>
  7. <%
  8. request.setCharacterEncoding("UTF-8");
  9. String data = request.getParameter("test");
  10. %>
  11. <body>
  12. <h1>FCKeditor - 显示数据</h1>
  13. <hr/><br />
  14. <%=data%>
  15. </body>
  16. </html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<head>
   <title>FCKeditor - 显示数据</title>
   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<%
   request.setCharacterEncoding("UTF-8");
   String data = request.getParameter("test");
%>
<body>
   <h1>FCKeditor - 显示数据</h1>  
   <hr/><br />
   <%=data%>
</body>
</html>

6、给FckEditor瘦身
      删除fckeditor目录下面所有以“_”开头的文件或者文件夹,像"_samples"、"_documentation.html“等
     删除fckeditor目录下面除了,fckconfig.js   fckpackage.xml fckstyles.xml   fcktemplates.xml外的所有文件,当然要保留editor文件夹
     删除fckeditor/editor/lang目录下面除了en.js、 zh-cn.js外的所有文件
     删除fckeditor\editor\filemanager目录下面的connectors文件夹
     删除editor\skins目录下面除了default下面的文件夹,这个里面是皮肤,共有三种,可以在fckconfig.js里面设置。
PS:有关中文乱码问题请参考:http://hi.baidu.com/huqiwen/blog/item/c709aa18fa187a0135fa4103.html

  • 大小: 12.8 KB
  • 大小: 12.1 KB

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。