LittleRain

          小雨不打傘 打傘雨不小

          JSP下FCKeditor的安裝

          ????????首先下載并解壓最新的FCKeditor到各自的目錄,一個是FCKeditor的核心文件,另一個是針對jsp的文件包
          下載地址:http://www.fckeditor.net/download

          ?????????接下來我們可以開始配置了。
          我是在eclipse下來配置的
          環境:
          jdk:1.4
          eclisp:3.12
          plugin:myeclipse4.0
          FCKeditor :FCKeditor_2.3.2
          FCKeditor.java:FCKeditor-2.3

          1.新建一個webproject,我這里取名為FCK。

          2.把FCKeditor_2.3.2目錄下的FCKeditor目錄拷貝到FCK工程的根目錄,即WebRoot目錄下。

          3.將FCKeditor-2.3\web\WEB-INF目錄下的web.xml中的兩個servlet,servlet-mapping定義復制到工程的web.xml文件中去。

          4.修改web.xml文件

          <servlet-mapping>?
          ????????<servlet-name>Connector</servlet-name>?
          ????????<url-pattern>/editor/filemanager/browser/default/connectors/jsp/connector</url-pattern>?
          ????</servlet-mapping>?

          ????<servlet-mapping>?
          ????????<servlet-name>SimpleUploader</servlet-name>?
          ????????<url-pattern>/editor/filemanager/upload/simpleuploader</url-pattern>??
          ?</servlet-mapping>

            為

          <servlet-mapping>?
          ????????<servlet-name>Connector</servlet-name>?
          ????????<url-pattern>/FCKeditor/editor/filemanager/browser/default/connectors/jsp/connector</url-pattern>?
          ????</servlet-mapping>?

          ????<servlet-mapping>?
          ????????<servlet-name>SimpleUploader</servlet-name>?
          ????????<url-pattern>/FCKeditor/editor/filemanager/upload/simpleuploader</url-pattern>??
          ??</servlet-mapping>

          這里的/FCKeditor/是對應你webroot目錄下的FCKeditor目錄。

          5.拷貝FCKeditor-2.3\web\WEB-INF\lib下的兩個jar包到WebRoot\WEB-INF\lib目錄下
          (在項目的庫中添加FCKeditor-2.3\web\WEB-INF\lib下的兩個jar包? 達不到同樣的效果,一定要拷貝到lib目錄下)

          6.在webroot目錄下新建一個jsp,使用默認的MyJsp.jsp即可。

          7. 文件開頭處加入? :
          <%@ taglib uri="
          8.在jsp中嵌入的代碼:在Jsp中使用
          方法一:(可能會出現:The requested resource (/FCK/editor/fckeditor.html) is not available)
          <c:set var="basepath"><c:url value="/fck/" /></c:set>
          <FCK:editor id="descn" basePath="${basepath}" height="500px">
          <c:out value="${book.descn}" escapeXml="false" default="" />
          </FCK:editor>

          方法二:
          <FCK:editor id="infoContent" basePath="/FCK/FCKeditor/"
          ????????????? width="800"
          ????????????? height="300"?????????????????????????
          ????????????? >
          ????????????? 請輸入內容
          </FCK:editor>

          9.部署好工程,開啟tomcat,打開MyJsp.jsp頁面即可。




          10.三種方法調用FCKeditor
          <%--
          三種方法調用FCKeditor
          1.FCKeditor自定義標簽 (必須加頭文件 <%@ taglib uri="/TestFCKeditor" prefix="FCK" %> )
          2.script腳本語言調用 (必須引用 腳本文件 <script type="text/javascript" src="/TestFCKeditor/FCKeditor/fckeditor.js"></script> )
          3.FCKeditor API 調用 (必須加頭文件 <%@ page language="java" import="com.fredck.FCKeditor.*" %> )
          --%>

          <%--
          <form action="show.jsp" method="post" target="_blank">
          <FCK:editor id="content" basePath="/TestFCKeditor/FCKeditor/"
          width="700"
          height="500"
          skinPath="/TestFCKeditor/FCKeditor/editor/skins/silver/"
          toolbarSet = "Default"
          >
          input
          </FCK:editor>
          <input type="submit" value="Submit">
          </form>
          --%>

          <form action="show.jsp" method="post" target="_blank">
          <table border="0" width="700"><tr><td>
          <textarea id="content" name="content" style="WIDTH: 100%; HEIGHT: 400px">input</textarea>
          <script type="text/javascript">
          var oFCKeditor = new FCKeditor('content') ;
          oFCKeditor.BasePath = "/TestFCKeditor/FCKeditor/" ;
          oFCKeditor.Height = 400;
          oFCKeditor.ToolbarSet = "Default" ;
          oFCKeditor.ReplaceTextarea();
          </script>
          <input type="submit" value="Submit">
          </td></tr></table>
          </form>

          <%--
          <form action="show.jsp" method="post" target="_blank">
          <%
          FCKeditor oFCKeditor ;
          oFCKeditor = new FCKeditor( request, "content" ) ;
          oFCKeditor.setBasePath( "/TestFCKeditor/FCKeditor/" ) ;
          oFCKeditor.setValue( "input" );
          out.println( oFCKeditor.create() ) ;
          %>
          <br>
          <input type="submit" value="Submit">
          </form>
          --%>

          添加文件/TestFCKeditor/show.jsp:
          <%
          String content = request.getParameter("content");
          out.print(content);
          out.println(request.getParameter("title"));
          %>
          <!--表單中的input的name可以等于這里request.getParameter("parameter") 中的parameter參數。可以通過out.println輸出
          <FCK:editor id="content".....>FCK中的id相當于input的name
          -->



          11.FCKeditor編輯器文件上傳配置

          FCKeditor編輯器的配置文件是fckconfig.js,其中有對編輯器各種默認屬性的設置。以下是fckeditor與java集成使用 時上傳文件的設置(需要注意的是編輯器不會自動創建文件上傳的文件夾,需要在項目的根目錄中手動添加),將fckeditor.js文件中以下幾個屬性原 來的值修改為如下設置:

          至此,即可使用FCKeditor的文件上傳功能。

          posted on 2006-11-10 12:42 小雨不打傘 閱讀(2222) 評論(2)  編輯  收藏 所屬分類: web學習心得

          評論

          # re: JSP下FCKeditor的安裝 2008-02-03 10:44 Rosekisser

          很好很實用!  回復  更多評論   

          # re: JSP下FCKeditor的安裝 2014-04-15 18:15 最代碼

          參考下這個代碼:jsp結合fckeditor使用的小demo分享http://www.zuidaima.com/share/1780911659551744.htm  回復  更多評論   

          公告

          點擊這里給我發消息 QQ:232720563


            MSN:new_haihua@hotmail.com

          導航

          統計

          常用鏈接

          留言簿(2)

          隨筆分類(51)

          最新隨筆

          積分與排名

          最新評論

          閱讀排行榜

          主站蜘蛛池模板: 偏关县| 鞍山市| 资兴市| 张家口市| 潞城市| 富阳市| 潼南县| 永定县| 大连市| 东乡族自治县| 华安县| 大港区| 曲沃县| 绥阳县| 蚌埠市| 巴塘县| 旅游| 湘潭市| 门源| 武宣县| 沙河市| 阜南县| 施秉县| 包头市| 平和县| 江津市| 六枝特区| 东宁县| 山东| 江华| 大名县| 延吉市| 武义县| 开封县| 依兰县| 哈尔滨市| 鄂托克前旗| 宜章县| 丹阳市| 宁城县| 大足县|