FCKeditor jsp 配置 使用

FCKeditor jsp 配置 使用

2009-04-07 16:57

FCKeditor是一款跨平臺的在線編輯器,到我發佈本文,FCKeditor的官方版本已經發展到了2.6.4

點擊進入 官網

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

      FCKeditor 2.6 Beta 下載地址:sourceforge.net/project/downloading.php

      FCKeditor.Java 下載地址:http://sourceforge.net/project/showfiles.php?group_id=75348&package_id=129511&release_id=348486

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

2、首先在Tomcat下建立一個虛擬目錄例如:test    http://localhost:8080/test

      將解壓後的FCKeditor_2.6b文件夾下的fckeditor拷貝到test目錄下,並重新命名爲FCKeditor

      將解壓後的FCKeditor-2.3文件夾下的web下的WEB-INF拷貝到test目錄下。

      FCKeditor-2.3文件夾下src下的FCKeditor.tld拷貝到test目錄下的WEB-INF下。

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

     將第37false改爲true,此處爲允許上傳。

改之前:
35   <init-param>
36    <param-name>enabled</param-name>
37    <param-value>false</param-value>
38   </init-param>
改之後:
37    <param-value>true</param-value>

     將第68行與73行中的fckeditor改爲FCKeditor

改之前:
66 <servlet-mapping>
67    <servlet-name>Connector</servlet-name>
68    <url-pattern>/editor/filemanager/browser/default/connectors/jsp/connector</url-pattern>
69 </servlet-mapping>
70
71 <servlet-mapping>
72    <servlet-name>SimpleUploader</servlet-name>
73    <url-pattern>/editor/filemanager/upload/simpleuploader</url-pattern>
74 </servlet-mapping>
改之後:
68    <url-pattern>/FCKeditor/editor/filemanager/browser/default/connectors/jsp/connector</url-pattern>
73    <url-pattern>/FCKeditor/editor/filemanager/upload/simpleuploader</url-pattern>

4、修改FCKeditor文件夾下的fckeditor.js

     修改第50行的FCKeditor.BasePath

改之後:
50 FCKeditor.BasePath = 'FCKeditor/' ;
(注意:FCKeditor之前是沒有/的)

5、修改FCKeditor文件夾下的fckconfig.js

     修改FCKConfig.DefaultLanguageFCKConfig.LinkBrowserURLFCKConfig.ImageBrowserURLFCKConfig.FlashBrowserURL

改之後:

FCKConfig.AutoDetectLanguage = false ;   注意:如果這裏沒有改爲false編輯器是不會顯示爲中文的
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' ;

6default.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>

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

--------------------------------------------------------------------------------------------------

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章