---
title: "WYSIWYG--fck(摘)"
author: "sjuhui"
date: "2008-05-15T14:22:15Z"
tags: ["ASP", "ASP.net", "Servlet", "fckeditor", "浏览器"]
slug: "wysiwyg-fck"
draft: false
lastmod: "2008-05-15T14:22:15Z"
id: 193267
url: "https://sjuhui.iteye.com/blog/193267"
---

fck--2.3  
说明： 1 后台推荐，前台用 BBcode 或者屏蔽 fck 的一些不安全因素  
        2 以下仅针对 java ， .net/php 等不完全吻合

**一：安装**  
1,FCKeditor 官司方网址： [http://www.fckeditor.net/](http://www.fckeditor.net/)  
FCKeditor 在线 DEMO ： [http://www.fckeditor.net/demo](http://www.fckeditor.net/demo)  
2,FCKeditor 在 java 中的应用  
FCKeditor 不能直接在 JSP 项目中使用，需要 FCKeditor.java 库的支持。  
FCKeditor.java 下载地址： [http://www.fckeditor.net/download](http://www.fckeditor.net/download) ( 最近版本为 2.3)  
3 ，步骤  
（ 1 ）下载 FCKeditor\_2.6.zip 包  
（ 2 ）解压 FCKeditor\_2.6.zip 包，放到 WebRoot 目录下的某个位置  
（ 3 ）解压 FCKeditor.java-2.3.zip 包，将其中的 \\web\\WEB-INF\\lib 下的 jar 文件到项目的 WebRoot\\WEB-INF\\lib 目录  
（ 4 ） web.xml 中

```
<!-- fck editor  servlet mapping -->
<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>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>
    <!--FCK editor-->
    <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>
<!-- fck editor  servlet mapping -->
   <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>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>
    <!--FCK editor-->
    <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>
       <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
      <servlet-name>Connector</servlet-name>
      <url-pattern>/resource/js/FCKeditor/editor/filemanager/browser/default/connectors/jsp/connector</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
     <servlet-name>SimpleUploader</servlet-name>
    <url-pattern>/resource/js/FCKeditor/editor/filemanager/upload/simpleuploader</url-pattern>
    </servlet-mapping>
        </init-param>
       <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>Connector</servlet-name>      
         <url-pattern>/resource/js/FCKeditor/editor/filemanager/browser/default/connectors/jsp/connector</url-pattern>
      </servlet-mapping>
    <servlet-mapping>
        <servlet-name>SimpleUploader</servlet-name>    
         <url-pattern>/resource/js/FCKeditor/editor/filemanager/upload/simpleuploader</url-pattern>
    </servlet-mapping>
```

 

（ 5 ） js 中新建， 'content' 为 textarea 的 id

```
 var oFCKeditor = new FCKeditor( 'content' ) ;
  oFCKeditor.ToolbarSet = 'Basic' ;
  oFCKeditor.BasePath = '<%=base%>/resource/js/FCKeditor/' ;
  oFCKeditor.Width = '100%' ;
  oFCKeditor.Height = '300' ;
oFCKeditor.ImageBrowserURL="/resource/js/FCKeditor/editor/filemanager/browser/default/browser.html?Type=Image&Connector=connectors/jsp/connector"
oFCKeditor.LinkBrowserURL="/resource/js/FCKeditor/editor/filemanager/browser/default/browser.html?Connector=connectors/jsp/connector"
oFCKeditor.FlashBrowserURL="/resource/js/FCKeditor/editor/filemanager/browser/default/browser.html?Type=Flash&Connector=connectors/jsp/connector"
oFCKeditor.ImageUploadURL="/resource/js/FCKeditor/editor/filemanager/upload/simpleuploader?Type=Image"
oFCKeditor.LinkUploadURL="/resource/js/FCKeditor/editor/filemanager/upload/simpleuploader?Type=File"
oFCKeditor.FlashUploadURL="/resource/js/FCKeditor/editor/filemanager/upload/simpleuploader?Type=Flash"
oFCKeditor.ReplaceTextarea(); 
```

(6) 配置 FCKEDITOR

FCKEDITOR 提供了一套用于定制其外观 , 特性及行为的设置集 . 主配置文件名为 Fckconfig.js 你既可以编辑主配置文件 , 也可以自己定义单独的配置文件 . 配置文件使用 JAVASCRIPT 语法 . 修改后 , 在建立编辑器时 , 可以使用以下语法 varoFCKeditor=newFCKeditor('FCKeditor1'); oFCKeditor.Config\['CustomConfigurationsPath']='/myconfig.js';  
oFCKeditor.Create();  
提醒 : 当你修改配置后 , 请清空浏览器缓存以查看效果  
配置选项 :  
AutoDetectLanguage=true/false 自动检测语言  
BaseHref="" 相对链接的基地址  
ContentLangDirection="ltr/rtl" 默认文字方向  
ContextMenu= 字符串数组 , 右键菜单的内容  
CustomConfigurationsPath="" 自定义配置文件路径和名称  
Debug=true/false 是否开启调试功能 , 这样 , 当调用 FCKDebug.Output() 时 , 会在调试窗中输出内容 DefaultLanguage="" 缺省语言  
EditorAreaCss="" 编辑区的样式表文件  
EnableSourceXHTML=true/false 为 TRUE 时 , 当由可视化界面切换到代码页时 , 把 HTML 处理成 XHTML  
EnableXHTML=true/false 是否允许使用 XHTML 取代 HTML  
FillEmptyBlocks=true/false 使用这个功能 , 可以将空的块级元素用空格来替代  
FontColors="" 设置显示颜色拾取器时文字颜色列表  
FontFormats="" 设置显示在文字格式列表中的命名  
FontNames="" 字体列表中的字体名  
FontSizes="" 字体大小中的字号列表  
ForcePasteAsPlainText=true/false 强制粘贴为纯文本  
ForceSimpleAmpersand=true/false

**二：设置**

1**:FCKeditor设置文件 "fckconfig.js"**  
FCKConfig.CustomConfigurationsPath = '' ; // 自定义配置文件路径和名称  
FCKConfig.EditorAreaCSS = FCKConfig.BasePath + 'css/fck\_editorarea.css'; // 编辑区的样式表文件  
FCKConfig.EditorAreaStyles = '' ; // 编辑区的样式表风格  
FCKConfig.ToolbarComboPreviewCSS =''; //工具栏预览CSS  
FCKConfig.DocType = '' ;//文档类型  
FCKConfig.BaseHref = ''; // 相对链接的基地址  
FCKConfig.FullPage = false ; //是否允许编辑整个HTML文件,还是仅允许编辑BODY间的内容  
FCKConfig.StartupShowBlocks = false ;//决定是否启用"显示模块"  
FCKConfig.Debug = false ;//是否开启调试功能  
FCKConfig.SkinPath = FCKConfig.BasePath + 'skins/default/' ; //皮肤路径  
FCKConfig.PreloadImages=... //预装入的图片  
FCKConfig.PluginsPath = FCKConfig.BasePath + 'plugins/' ; //插件路径  
FCKConfig.AutoDetectLanguage = true ; //是否自动检测语言  
FCKConfig.DefaultLanguage  = 'zh-cn' ; //默认语言  
FCKConfig.ContentLangDirection = 'ltr' ; //默认的文字方向,可选"ltr/rtl",即从左到右或从右到左  
FCKConfig.ProcessHTMLEntities = true ; //处理HTML实体  
FCKConfig.IncludeLatinEntities = true ; //包括拉丁文  
FCKConfig.IncludeGreekEntities = true ;//包括希腊文  
FCKConfig.ProcessNumericEntities = false ;//处理数字实体  
FCKConfig.AdditionalNumericEntities = ''  ;  //附加的数字实体  
FCKConfig.FillEmptyBlocks = true ; //是否填充空块  
FCKConfig.FormatSource  = true ; //在切换到代码视图时是否自动格式化代码  
FCKConfig.FormatOutput  = true ; //当输出内容时是否自动格式化代码  
FCKConfig.FormatIndentator = '    ' ; //当在源码格式下缩进代码使用的字符  
FCKConfig.StartupFocus = false ; //开启时焦点是否到编辑器,即打开页面时光标是否停留在fckeditor上  
FCKConfig.ForcePasteAsPlainText = false ; //是否强制粘贴为纯文件内容  
FCKConfig.AutoDetectPasteFromWord = true ; //是否自动探测从word粘贴文件,仅支持IE  
FCKConfig.ShowDropDialog = true ;//是否显示下拉菜单  
FCKConfig.ForceSimpleAmpersand = false ;//是否不把&符号转换为XML实体  
FCKConfig.TabSpaces  = 0 ;//按下Tab键时光标跳格数,默认值为零为不跳格  
FCKConfig.ShowBorders = true ;//合并边框  
FCKConfig.SourcePopup = false ;//弹出  
FCKConfig.ToolbarStartExpanded = true ;//启动fckeditor工具栏默认是否展开  
FCKConfig.ToolbarCanCollapse = true ;//是否允许折叠或展开工具栏  
FCKConfig.IgnoreEmptyParagraphValue = true ;//是否忽略空的段落值  
FCKConfig.FloatingPanelsZIndex = 10000 ;//浮动面板索引  
FCKConfig.HtmlEncodeOutput = false ;//是否将HTML编码输出  
FCKConfig.TemplateReplaceAll = true ;//是否替换所有模板  
FCKConfig.ToolbarLocation = 'In' ;//工具栏位置,  
FCKConfig.CustomConfigurationsPath = '' ; // 自定义配置文件路径和名称  
FCKConfig.EditorAreaCSS = FCKConfig.BasePath + 'css/fck\_editorarea.css'; // 编辑区的样式表文件  
FCKConfig.BaseHref = ''; // 相对链接的基地址  
FCKConfig.Debug = true/false; // 是否开启调试功能，当调用FCKDebug.Output()时，会在调试窗中输出内容  
FCKConfig.SkinPath = FCKConfig.BasePath + 'skins/default/'; // 设置皮肤  
FCKConfig.AutoDetectLanguage = true/false ; // 是否自动检测语言  
FCKConfig.DefaultLanguage = 'zh-cn' ; // 设置默认语言  
FCKConfig.ContentLangDirection = 'ltr/rtr'; // 默认文字方向，ltr左，rtr右  
FCKConfig.FillEmptyBlocks = true/false ; // 使用这个功能，可以将空的块级元素用空格来替代  
FCKConfig.FormatSource = true/false; // 切换到代码视图时，是否自动格式化代码  
FCKConfig.FormatOutput = true/false; // 当输出内容时是否自动格式化代码  
FCKConfig.FormatIndentator = ""; // 当在“源码格式”下缩进代码使用的字符  
FCKConfig.GeckoUseSPAN = true/false; // 是否允许SPAN标记代替B，I，U标记  
FCKConfig.StartupFocus = true/false; // 开启时是否FOCUS到编辑器  
FCKConfig.ForcePasteAsPlainText = true/false;// 强制粘贴为纯文本  
FCKConfig.ForceSimpleAmpersand = true/false; // 是否不把&符号转换为XML实体  
FCKConfig.TabSpaces = 0/1; // TAB是否有效  
FCKConfig.TabSpaces = 4; // TAB键产生的空格字符数  
FCKConfig.ShowBorders = true/false; // 是否合并边框  
FCKConfig.ToolbarStartExpanded = true/false; // 页面载入时，工具栏是否展开，点“展开工具栏”时才出现  
FCKConfig.ToolBarCanCollapse = true/false; // 是否允许展开折叠工具栏  
FCKConfig.ToolbarSets = object ; // 编辑器的工具栏，可以自行定义，删减，可参考已存在工具栏  
FCKConfig.EnterMode = 'p'; // 编辑器中直接回车，在代码中生成，可选为p | div | br  
FCKConfig.ShiftEnterMode = 'br'; // 编辑器中Shift+回车，在代码中生成，可选为p | div | br  
FCKConfig.ContextMenu = 字符串数组; // 右键菜单的内容  
FCKConfig.FontColors = ""; // 文字颜色列表  
FCKConfig.FontNames = ""; // 字体列表  
FCKConfig.FontSizes = ""; // 字号列表  
FCKConfig.FontFormats = ""; // 文字格式列表  
FCKConfig.StylesXmlPath = ""; // CSS样式列表的XML文件的位置  
FCKConfig.TemplatesXmlPath = ""; // 模版的XML文件位置  
FCKConfig.SpellChecker = "ieSpell/Spellerpages"; // 拼写检查器  
FCKConfig.IeSpellDownloadUrl = ""; // 下载拼写检查器的网址  
FCKConfig.SmileyPath = FCKConfig.BasePath + 'images/smiley/msn/'; // 表情文件存放路径  
FCKConfig.SmileyImages = ''; // 表情文件名称列表，具体参考默认设置  
FCKConfig.SmileyColumns = 8; // 表情窗口显示表情列数  
FCKConfig.SmileyWindowWidth = 320; // 表情窗口显示宽度，此窗口会因为表情文件的改变而作调整  
FCKConfig.SmileyWindowHeight = 240; // 表情窗口显示高度，此窗口会因为表情文件的改变而作调整  
FCKConfig.FullPage = true/false; // 是否允许编辑整个HTML文件，还是仅允许编辑BODY间的内容

  **上传设置**

var \_FileBrowserLanguage         = 'php' ;         // asp | aspx | cfm | lasso | perl | php | py     
var \_QuickUploadLanguage         = 'php' ;         // asp | aspx | cfm | lasso | php\[/code]  
//第一个是文件浏览器使用的语言，第二个快速上传使用的语言，改成你需要的  
FCKConfig.LinkUploadAllowedExtensions         = "" ;                         // empty for all  
FCKConfig.LinkUploadDeniedExtensions =".(php|php3|php5|phtml|asp|aspx|ascx|jsp|cfm|cfc|pl|bat|exe|dll|reg|cgi)$"  
//这是两个允许和拒绝上传的文件类型列表  
FCKConfig.ImageBrowser = false ;是否在插入图片功能里面启用服务器文件浏览功能  
FCKConfig.ImageBrowserURL = FCKConfig.BasePath + 'filemanager/browser/default/browser.html?Type=Image&Connector=connectors/' + \_FileBrowserLanguage + '/connector.' + \_FileBrowserExtension ;  
Type=Image   表示文件类型是image这会使文件浏览器定位到文件上传路径/image/文件夹下面  
FCKConfig.FlashBrowser = false ;是否在插入flash功能中启用服务器文件浏览功能  
FCKConfig.LinkUpload = false ;是否启用插入链接的快速上传功能  
FCKConfig.ImageUpload = false ;是否启用图片快速上传功能  
FCKConfig.FlashUpload = false ;是否启用flash上传功能

**服务器文件设置**

文件浏览器的设置：  
fckeditor\\editor\\filemanager\\connectors\\asp\\config.asp

ConfigIsEnabled = true 决定是否启用文件浏览器。这个是在服务器上执行的  
ConfigUserFilesPath = "/test/upload/" 上传文件的路径（相对的）  
ConfigAllowedExtensions.Add         "File", ""  
ConfigDeniedExtensions.Add         "File", "php|php2|php3|php4|php5|phtml|pwml|inc|asp|aspx|ascx|jsp|cfm|cfc|pl|bat|exe|com|dll|vbs|js|reg|cgi"  
ConfigAllowedExtensions.Add         "Image", "jpg|gif|jpeg|png|bmp"  
ConfigDeniedExtensions.Add         "Image", ""  
ConfigAllowedExtensions.Add         "Flash", "swf|fla"  
ConfigDeniedExtensions.Add         "Flash", ""  
ConfigAllowedExtensions.Add         "Media", "swf|fla|jpg|gif|jpeg|png|avi|mpg|mpeg|mp(1-4)|wma|wmv|wav|mid|midi|rmi|rm|ram|rmvb|mov|qt"  
ConfigDeniedExtensions.Add         "Media", ""

这是4个不同的filetype类型 分别对应了 前台编辑器的 插入链接 插入图片 插入flash 插入媒体 4个功能  
connecter.asp

Function IsAllowedType( resourceType )  
         Dim orE  
         Set orE         = New RegExp  
         orE.IgnoreCase         = True  
         orE.Global                 = True  
         orE.Pattern                 = "^(File|Image|Flash|Media)$" ‘这里也是文件类型  
          
         IsAllowedType = orE.Test( resourceType )  
          
         Set orE         = Nothing  
End Function

这里的文件类型与上面提到的两处文件类型是一致的要改必须许全改

快速上传：  
ConfigIsEnabled = False //是否启用快速上传  
ConfigUserFilesPath = "/UserFiles/"

//如果想上传到 /test/upload/yyymmdd/的文件夹下面  
则修改为 ConfigUserFilesPath = "/test/upload/" & year(now())& right("0"& month(now()),2)&right("0" & day(now()),2)

**2:关于FCK editor瘦身要点如下：**  
1.将FCK editor目录下及子目录下所有以"\_"下划线开头的文件夹删除  
2.FCK editor根目录下只保留fck config.js, fck editor.js, fck styles.xml, fck templates.xml，其余全部删除  
3.将editor/filemanager/upload目录下文件及文件夹清空  
4.将/editor/filemanager/browser/default/connectors/下的所有文件删除  
5.还可以将editor/skins目录下的皮肤文件删除，只留下default一套皮肤（如果你不需要换皮肤的话  
6.还可以将editor/lang目录下文件删除，只保留en.js, fck languagemanager.js, zh-cn.js, zh.js文件  
7.如果你是使用javascript来调用加载FCK editor，那么就不需要在web.xml中配置fck editor的tag文件。  
8.还有一个问题刚开始使用FCK editor的人常会遇到就怎么控制它的toolbar的大小和元素排列，其实很简单。  
在fck config.js中用这样的标签\[]来划分每行的元素的多少，这样就可以控制toolbar的长短和大小了，具体示例参看：fck config.js中的toolbarset\["Default"]  
＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝  
用fck config.js中的一些选项来控制toolbarset中控件的功能，实现功能裁剪：  
1)：取消超链接中的浏览服务器和上传功能，方法如下：  
－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－  
FCK Config.LinkBrowser = true;  
FCK Config.LinkUpload = true;  
改为：  
FCK Config.LinkBrowser = false;  
FCK Config.LinkUpload = false;  
－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－  
2)：取消图片链接中的浏览服务器和上传功能，方法如下：  
－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－  
FCK Config.ImageUpload = true;  
FCK Config.ImageBrowser = true;  
改为：  
FCK Config.ImageUpload = false;  
FCK Config.ImageBrowser = false;  
－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－  
3)：Dlg Button中取消高级功能，方法如下：  
FCK Config.LinkDlgHideAdvanced = false ;  
FCK Config.ImageDlgHideAdvanced = false ;  
改为：  
FCK Config.ImageDlgHideAdvanced = true ;  
FCK Config.LinkDlgHideTarget = true ;

**4介绍FCK editor的上传和浏览服务器功能，以及如何在里面实现动态** 超连接，转发到servlet经过filter以后去调用服务器的action如何实现对应用户浏览自己的图片的列表实现！  
＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝  
FCK editor集成java servlet可以实现文件的上传和服务器端列表读取功能FCK editor自己提供了两个servlet来分别实现上传文件功能，和读取服务器端文件列表功能，这两个servlet分别为：  
com.fredck.FCK editor.connector.ConnectorServlet（读取文件列表）  
com.fredck.FCK editor.uploader.SimpleUploaderServlet（实现文件上传）  
1.浏览服务器端文件列表  
－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－  
web.xml文件中，比如：ConnectorServlet中的配置选项：  
&lt;init-param&gt;  
    &lt;param-name&gt;baseDir&lt;/param-name&gt;  
    &lt;param-value&gt;/UserFiles/&lt;/param-value&gt;  
&lt;/init-param&gt;

意思是在浏览服务器上的baseDir配置指定里面的所有文件及其目录结构列表。  
如果你的baseDir没有配置，Connector将会自动创建一个默认的文件夹  
UserFiles，对应的ConnectorServlet中init()方法中代码如下：  
－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－  
baseDir = getInitParameter("baseDir");  
if (baseDir == null)  
baseDir = "/UserFiles/";

－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－  
还想说一下的是，FCK editor 的client调用server的servlet方法采用的是Ajax思想来实现。当你点击浏览服务器(browser server)的时候就会触发一个异步的javascript + xmlhttp的调用响应，后台的servlet会去完成你要请求的事件，然后数据以xml方式返回给client来解析。很明显，你要实现去数据库或者 其他的文件系统请求列表，你只要修改  
ConnectorServlet中两个私有方法：getFolders 和 getFiles

让 它去你指定的地方得到文件列表即可，这样你的文件可以放在任何你指定目录下。多说一句，很多人都想知道个人blog系统中怎么实现上传文件以后对应用户浏 览自己的列表的，我的做法很简单，建立你用户名的文件夹，你上传只能上传到你的目录夹，浏览可以通过程序指定浏览对应用户下的文件夹即可，这个时候你要修 改Connectorservlet中的路径即可！  
－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－

2.超连接重定位问题  
－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－  
FCK editor可以插入超连接，实现对文件的预览功能，只要我们稍微改变我们可以使FCK editor编辑器支持对任意文件系统下的任意文件的客户端浏览和下载保存！FCK editor 本来提供的是相对URL超链接，只要我们修改ConnectorServlet中传递给客户端的地址的时候，把它改写成绝对URL然后再通过我们自己的 filter的servlet实现重定向去一个下载/浏览文件的struts的action方法就可以实现在客户端对超连接文件的下载和浏览！说一下具体 做法吧：

1)：修改ConnectorServlet传递给客户端javascript的路径，代码如下：  
String currentUrl = "http://" + request.getserver +request.getServerPort + request.getContextPath + resourcePath;

以上代码请在ConnectorServlet的doGet()里面拼装！在调用CreateCommonXml()私有方法的时候参数传入：  
myEl.setAttribute("path",currentPath);  
myEl.setAttribute("url",currentUrl);

提醒一下resourcePath为在web.xml配置文件中ConnectorServlet中的一个初始化参数配置，等一下利用filter实现对超连接的重定位就提取URL中的这个配置参数来判断，配置如下  
&lt;init-param&gt;  
    &lt;param-name&gt;resourcePath&lt;/param-name&gt;  
    &lt;param-value&gt;/fileSystem/&lt;/param-value&gt;  
&lt;/init-param&gt;

2)：建立你的filter servlet，实现对URL的截获，对符合要求的URL进行重定位到你的对应action中去即可  
3)：实现你的对应action来实现文件的上传和下载功能即可！  
4)： 扩展功能－实现对URL的加密，对连接的URL中加上一串字符，最后几位作为算法校验，对不符合要求的URL连接,filter将会拒绝重定位到指定 action。此外利用自己写的扩展类还可以实现对超连接的文件类型进行限制，比如你只能超连接JPG|GIF|DOC|TXT|HTML等几种后缀名的 文件，对其他文件即使你指定超连接也让你浏览和下载，这些都可以在web.xml中通过修改对应servlet的配置文件的初始化参数实现。

3.页面javascript修改  
－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－  
浏 览服务器的功能对应的html/javascript相关的文件为：browser.html和frmresourcelist.html对应你想传递的 信息你可以append在文件名的字符串后面，在GetFileRowHtml()的javascript函数中实现对文件名的截取，这样client只 会显示文件名，而你可以得到文件的数据库唯一标识，任何你想要的信息你都可以通过修改ConnectorServlet中的私有方法getFiles() 来实现，只要修改页面frmresurcelist.html中的GetFileRowHtml()中传入变量fileName即可。你还可以在点击选中 文件的时候实现一个你自己的Ajax调用，一切取决你的项目需要！

 

 

\_\_\_\_\_\_\_\_\_\_\__

自定义工具栏安装：  
1：http://bokee.shinylife.net/blog/article.asp?id=692  
http://www.cnblogs.com/goody9807/archive/2008/02/15/1070024.html  
http://blog.csdn.net/flying\_huang/archive/2007/03/23/1539206.aspx  
2：

```
Code highlighting produced by Actipro CodeHighlighter (freeware)

http://www.CodeHighlighter.com/





    <script type="text/javascript">

<!--

// FCKeditor_OnComplete is a special function that is called when an editor

// instance is loaded ad available to the API. It must be named exactly in

// this way.

function FCKeditor_OnComplete( editorInstance )

{

    // Show the editor name and description in the browser status bar.

    document.getElementById('eMessage').innerHTML = 'Instance "'   editorInstance.Name   '" loaded - '   editorInstance.Description ;



    // Show this sample buttons.

    document.getElementById('eButtons').style.visibility = '' ;

}



function InsertHTML()

{

    // Get the editor instance that we want to interact with.

    var oEditor = FCKeditorAPI.GetInstance('FCKeditor1') ;



    // Check the active editing mode.

    if ( oEditor.EditMode == FCK_EDITMODE_WYSIWYG )

    {

        // Insert the desired HTML.

        oEditor.InsertHtml( '- This is some <a href="/Test1.html">sample<\/a> HTML -' ) ;

    }

    else

        alert( 'You must be on WYSIWYG mode!' ) ;

}



function SetContents()

{

    // Get the editor instance that we want to interact with.

    var oEditor = FCKeditorAPI.GetInstance('FCKeditor1') ;



    // Set the editor contents (replace the actual one).

    oEditor.SetData( 'This is the <b>new content<\/b> I want in the editor.' ) ;

}



function GetContents()

{

    // Get the editor instance that we want to interact with.

    var oEditor = FCKeditorAPI.GetInstance('FCKeditor1') ;



    // Get the editor contents in XHTML.

    alert( oEditor.GetXHTML( true ) ) ;        // "true" means you want it formatted.

}



function ExecuteCommand( commandName )

{

    // Get the editor instance that we want to interact with.

    var oEditor = FCKeditorAPI.GetInstance('FCKeditor1') ;



    // Execute the command.

    oEditor.Commands.GetCommand( commandName ).Execute() ;

}



function GetLength()

{

    // This functions shows that you can interact directly with the editor area

    // DOM. In this way you have the freedom to do anything you want with it.



    // Get the editor instance that we want to interact with.

    var oEditor = FCKeditorAPI.GetInstance('FCKeditor1') ;



    // Get the Editor Area DOM (Document object).

    var oDOM = oEditor.EditorDocument ;



    var iLength ;



    // The are two diffent ways to get the text (without HTML markups).

    // It is browser specific.



    if ( document.all )        // If Internet Explorer.

    {

        iLength = oDOM.body.innerText.length ;

    }

    else                    // If Gecko.

    {

        var r = oDOM.createRange() ;

        r.selectNodeContents( oDOM.body ) ;

        iLength = r.toString().length ;

    }



    alert( 'Actual text length (without HTML markups): '   iLength   ' characters' ) ;

}



function GetInnerHTML()

{

    // Get the editor instance that we want to interact with.

    var oEditor = FCKeditorAPI.GetInstance('FCKeditor1') ;



    alert( oEditor.EditorDocument.body.innerHTML ) ;

}



function CheckIsDirty()

{

    // Get the editor instance that we want to interact with.

    var oEditor = FCKeditorAPI.GetInstance('FCKeditor1') ;

    alert( oEditor.IsDirty() ) ;

}



function ResetIsDirty()

{

    // Get the editor instance that we want to interact with.

    var oEditor = FCKeditorAPI.GetInstance('FCKeditor1') ;

    oEditor.ResetIsDirty() ;

    alert( 'The "IsDirty" status has been reset' ) ;

}

-->

    </script>
```