常用的富文本框插件FreeTextBox、CuteEditor、CKEditor、FCKEditor、TinyMCE、KindEditor ;和CKEditor實例


目前市面上用的比較多的富文本編輯器有:

FreeTextBox 一個有很多年歷史的富文本編輯器了,使用簡單,而且一般的使用是免費的,但是不開源,上傳圖片上傳附件等功能沒有,擴展性差。

CuteEditor最強大的富文本編輯器,巨牛無比,但是是收費的,個人使用的話用下破解版倒無所謂,要想在企業中使用那就得買了,所以雖然強大,但是想節約的話就不考慮這個了。看看他的菜單就知道他有多牛了:


FCKEditor(升級版CKEditor)強大的開源富文本編輯器,各個語言中都可以使用。支持上傳圖片、Flash等,功能強擴展性強。



TinyMCE 也是一個開源的富文本編輯器,不過名氣沒有FCKEditor大,功能還是不錯。


KindEditor 一個國人開發的富文本編輯器,貌似還不錯,沒有深入研究。



下面我寫了一個很簡單CKEditor實例

web.xml

 

  1. <?xml version="1.0" encoding="UTF-8"?> 
  2. <web-app version="2.5"  
  3.     xmlns="http://java.sun.com/xml/ns/javaee"  
  4.     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
  5.     xsi:schemaLocation="http://java.sun.com/xml/ns/javaee  
  6.     http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> 
  7.     <filter> 
  8.         <filter-name>struts2</filter-name> 
  9.         <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class> 
  10.     </filter> 
  11.     <filter-mapping> 
  12.         <filter-name>struts2</filter-name> 
  13.         <url-pattern>/*</url-pattern> 
  14.     </filter-mapping> 
  15.      
  16.   <welcome-file-list> 
  17.     <welcome-file>index.jsp</welcome-file> 
  18.   </welcome-file-list> 
  19. </web-app> 
CkeditorAction

 

 

  1. import com.opensymphony.xwork2.ActionSupport; 
  2.  
  3. public class CkeditorAction extends ActionSupport{ 
  4.     private String editor1; 
  5.      
  6.     public String execute(){ 
  7.         <strong>System.out.println(editor1);</strong> 
  8.         return SUCCESS; 
  9.     } 
  10.      
  11.  
  12.     public String getEditor1() { 
  13.         return editor1; 
  14.     } 
  15.     public void setEditor1(String editor1) { 
  16.         this.editor1 = editor1; 
  17.     } 
在控制台打印使用CKEditor從頁面傳過來的的CKEditor文本內容,

 



struts.xml

 

  1. <?xml version="1.0" encoding="UTF-8" ?> 
  2. <!DOCTYPE struts PUBLIC 
  3.     "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" 
  4.     "http://struts.apache.org/dtds/struts-2.0.dtd"> 
  5.  
  6. <struts> 
  7.     <package name="wan" extends="struts-default"> 
  8.         <!--導出Ckeditor  --> 
  9.         <action name="Ckeditor" class="com.wanwan.app.action.CkeditorAction"> 
  10.             <result name="success">/ce/uploadImage.jsp</result> 
  11.         </action> 
  12.     </package> 
  13.  
  14. </struts>    
index.jsp
  1. <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> 
  2. <
  3. String path = request.getContextPath(); 
  4. String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; 
  5. %>  
  6. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 
  7. <html> 
  8.   <head> 
  9.     <base href="<%=basePath%>">  
  10.     <title>富文本框</title>  
  11.     <strong><script type="text/javascript" src="ckeditor/ckeditor.js"></script></strong> 
  12.     <script type="text/javascript">   
  13.     </script>   
  14.   </head> 
  15.   <body> 
  16.     <form action="Ckeditor" method="post" > 
  17.         <strong><textarea id="editor1" name="editor1"><p>Initial value.</p></textarea><br/> 
  18.         <script type="text/javascript">   
  19.             CKEDITOR.replace( 'editor1' );   
  20.         </script></strong> 
  21.         <input type="submit" value="提交">  
  22.         </form> 
  23.   </body> 
  24. </html> 

 

注意粗體部分,引用ckeditor



說明:以上代碼是將CKEditor文本類容傳到action,並且在action打印出來,相信看到的人會連接數據庫,這里我就不寫了,一般數據庫類型可以用大文本或者CLOB,當然可以直接生成一個靜態頁面,


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM