设为首页收藏本站
开启辅助访问
切换到宽版

创星网络[分享知识 传递快乐]

 找回密码
 立即注册

QQ登录

只需一步,快速开始

用新浪微博登录

只需一步,快速搞定

搜索
查看: 3195|回复: 0
打印 上一主题 下一主题

FCK虚拟目录

[复制链接]
跳转到指定楼层
楼主
发表于 2012-12-11 23:53:37 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
我用FCK时还出现了一个问题,就是不希望把上传的图片放在工程下面,这样对应用环境下可以进行代码更新时,很不方便,不过FCK也提供了接口,只要实现就好了。

第一步:实现ContextPathBuilder接口
  1. import javax.servlet.http.HttpServletRequest;

  2. import net.fckeditor.handlers.PropertiesLoader;
  3. import net.fckeditor.requestcycle.impl.ContextPathBuilder;

  4. import com.clubgold.btg.sft.bean.Merchant;

  5. public class UserPathBuilderImpl extends ContextPathBuilder  {
  6.         
  7.         
  8.     // 虚拟目录设置
  9.     public String getUserFilesAbsolutePath(HttpServletRequest request) {

  10.         StringBuffer userFilesPathBuffer = new StringBuffer();

  11.         // 获得定义connector.userFilesAbsolutePath的值
  12.         String path = PropertiesLoader.getProperty("connector.userFilesAbsolutePath");
  13.         userFilesPathBuffer.append(path);
  14.         userFilesPathBuffer.append(System.getProperty("file.separator"));

  15.         Merchant merchant = (Merchant) request.getSession().getAttribute("merchant");
  16.         String userPath = "userDefault";
  17.         if (merchant != null) {
  18.             userPath = String.valueOf(merchant.getId());
  19.         }
  20.         userFilesPathBuffer.append(userPath);
  21.         return userFilesPathBuffer.toString();
  22.     }

  23.     // FCK目录设置
  24.     public String getUserFilesPath(HttpServletRequest request) {

  25.         StringBuffer userFilesPathBuffer = new StringBuffer();

  26.         // 获得定义connector.userFilesPath的值
  27.         String path = PropertiesLoader.getProperty("connector.userFilesPath");
  28.         userFilesPathBuffer.append(path);
  29.         userFilesPathBuffer.append("/");

  30.         Merchant merchant = (Merchant) request.getSession().getAttribute("merchant");
  31.         String userPath = "userDefault";
  32.         if (merchant != null) {
  33.             userPath = String.valueOf(merchant.getId());
  34.         }
  35.         userFilesPathBuffer.append(userPath);

  36.         return userFilesPathBuffer.toString();

  37.     }
  38. }
复制代码
当然,这次主要是getUserFilesAbsolutePath方法

第二步:进行设置
在fckeditor.properties中加入下面设置

connector.userActionImpl=net.fckeditor.requestcycle.impl.EnabledUserAction
connector.userPathBuilderImpl=com.clubgold.btg.sft.util.fck.UserPathBuilderImpl
connector.impl=net.fckeditor.connector.impl.LocalConnector
connector.userFilesPath=http://192.168.0.34
connector.userFilesAbsolutePath=D:/tmp/sftimage

这里connector.userFilesPath配置的虚拟路径
connector.userFilesAbsolutePath配置的是虚拟路径所对应的真实路径

第三步:虚拟路径的配置
FCK当然没有指定虚拟路径的能力,而且这也不是他能管的事,有很多方式进行虚拟路径的配置,比如TOMCAT或别的什么,我这里使用的是APACHE进行配置的,就是把APACHE给搭建起来就好了,指向192.168.0.34(这是我自己机器的IP)机器上的一个目录中就行(这里是D:/tmp/sftimage,要于connector.userFilesAbsolutePath所指向的目录一致就OK了),如何配置APACHE网上的很多,我就不细说了

from:http://go.cxweb.com.cn/rtb6t
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 转播转播 分享分享 分享淘帖
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|创星网络 ( 苏ICP备11027519号|网站地图  

GMT+8, 2024-9-22 07:23 , Processed in 0.088535 second(s), 25 queries .

Powered by Discuz! X3

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表