FCKeditor2.6 for JSP 配置方法

來源:互聯網
上載者:User

1、首先登陸www.fckeditor.net/download下載FCKeditor的最新版本,需要下載2個壓縮包,一個是基本應用,另一個是在為在jsp下所準備的配置。

      FCKeditor 2.6 :sourceforge.net/project/downloading.php

      FCKeditor.Java :sourceforge.net/project/downloading.php

下載之後分別為:FCKeditor_2.6.zip 和 FCKeditor-2.3.zip 將它們分別解壓。

2、首先在Eclipse下建立一個新項目例如:test    即http://localhost:8080/test

     在項目中建立檔案夾 FCKeditor,然後將解壓後的FCKeditor_2.6下fckeditor裡面的editor、fckconfig.js、fckeditor.js、fckstyles.xml、fcktemplates.xml拷貝到FCKeditor目錄下

      將解壓後的FCKeditor-2.3檔案夾中web/WEB-INF/lib下的包拷貝到test項目的lib中。

      將FCKeditor-2.3檔案夾下src下的FCKeditor.tld拷貝到test項目的WEB-INF下。

3、修改WEB-INF下的web.xml, 如下:

     <servlet>
       <servlet-name>Connector</servlet-name>
       <servlet-class>com.fredck.FCKeditor.connector.ConnectorServlet</servlet-class>
       <init-param>
           <param-name>baseDir</param-name>
           <param-value>/UserFiles/</param-value>
       </init-param>
       <init-param>
           <param-name>debug</param-name>
           <param-value>true</param-value>
       </init-param>
       <load-on-startup>1</load-on-startup>
   </servlet>

   <servlet>
       <servlet-name>SimpleUploader</servlet-name>
       <servlet-class>com.fredck.FCKeditor.uploader.SimpleUploaderServlet</servlet-class>
       <init-param>
           <param-name>baseDir</param-name>
           <param-value>/UserFiles/</param-value>
       </init-param>
       <init-param>
           <param-name>debug</param-name>
           <param-value>true</param-value>
       </init-param>
       <init-param>
           <param-name>enabled</param-name>
           <param-value>true</param-value>
       </init-param>
       <init-param>
           <param-name>AllowedExtensionsFile</param-name>
           <param-value></param-value>
       </init-param>
       <init-param>
           <param-name>DeniedExtensionsFile</param-name>
           <param-value>php|php3|php5|phtml|asp|aspx|ascx|jsp|cfm|cfc|pl|bat|exe|dll|reg|cgi</param-value>
       </init-param>
       <init-param>
           <param-name>AllowedExtensionsImage</param-name>
           <param-value>jpg|gif|jpeg|png|bmp</param-value>
       </init-param>
       <init-param>
           <param-name>DeniedExtensionsImage</param-name>
           <param-value></param-value>
       </init-param>
       <init-param>
           <param-name>AllowedExtensionsFlash</param-name>
           <param-value>swf|fla</param-value>
       </init-param>
       <init-param>
           <param-name>DeniedExtensionsFlash</param-name>
           <param-value></param-value>
       </init-param>
       <load-on-startup>1</load-on-startup>
   </servlet>

<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>

4、修改FCKeditor檔案夾下的fckeditor.js

     修改第50行的FCKeditor.BasePath。

改之後:
50 FCKeditor.BasePath = 'FCKeditor/' ;

5、修改FCKeditor檔案夾下的fckconfig.js

     修改FCKConfig.DefaultLanguage、FCKConfig.LinkBrowserURL、FCKConfig.ImageBrowserURL、FCKConfig.FlashBrowserURL、

改之後:
FCKConfig.DefaultLanguage   = 'zh-cn' ;

FCKConfig.LinkBrowserURL = FCKConfig.BasePath + "filemanager/browser/default/browser.html?Connector=connectors/jsp/connector" ;

FCKConfig.ImageBrowserURL = FCKConfig.BasePath + "filemanager/browser/default/browser.html?Type=Image&Connector=connectors/jsp/connector" ;

FCKConfig.FlashBrowserURL = FCKConfig.BasePath + "filemanager/browser/default/browser.html?Type=Flash&Connector=connectors/jsp/connector" ;

FCKConfig.LinkUploadURL = FCKConfig.BasePath + 'filemanager/upload/simpleuploader?Type=File' ;

FCKConfig.ImageUploadURL = FCKConfig.BasePath + 'filemanager/upload/simpleuploader?Type=Image' ;

FCKConfig.FlashUploadURL = FCKConfig.BasePath + 'filemanager/upload/simpleuploader?Type=Flash' ;

6、default.jsp內容如下:

<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>FCKeditor測試</title>
<script type="text/javascript" src="FCKeditor/fckeditor.js"></script>
</head>

<body>
<form id="form1" name="form1" method="post" action="default_do.jsp">
<table width="100%" border="0">
<tr>
    <td height="25">
      <textarea name="contest" id="contest" style="width:100%; height:400px;"></textarea>
<script type="text/javascript">
var oFCKeditor = new FCKeditor( 'contest' ) ;
//oFCKeditor.BasePath = 'FCKeditor/' ;
oFCKeditor.ToolbarSet = 'Default' ;
oFCKeditor.Width = '100%' ;
oFCKeditor.Height = '400' ;
oFCKeditor.Value = '' ;
oFCKeditor.ReplaceTextarea();
//oFCKeditor.Create() ;
</script>
      <input type="submit" name="Submit" value="提交" />
    </td>
</tr>
</table>
</form>
</body>
</html>

7、default_do.jsp內容如下:

<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>FCKeditor測試接收結果</title>
</head>

<body>
<%
    String contest = new String(request.getParameter("contest").getBytes("ISO8859_1"), "GB2312");
out.print(contest);
%>
</body>
</html>

最後測試:http://localhost:8080/test/default.jsp

圖1:

圖2:

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.