FCK虚拟目录

我用FCK时还出现了一个问题,就是不希望把上传的图片放在工程下面,这样对应用环境下可以进行代码更新时,很不方便,不过FCK也提供了接口,只要实现就好了。

第一步:实现ContextPathBuilder接口

import javax.servlet.http.HttpServletRequest;

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

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

public class UserPathBuilderImpl extends ContextPathBuilder {


// 虚拟目录设置
public String getUserFilesAbsolutePath(HttpServletRequest request) {

StringBuffer userFilesPathBuffer = new StringBuffer();

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

Merchant merchant = (Merchant) request.getSession().getAttribute("merchant");
String userPath = "userDefault";
if (merchant != null) {
userPath = String.valueOf(merchant.getId());
}
userFilesPathBuffer.append(userPath);
return userFilesPathBuffer.toString();
}

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

StringBuffer userFilesPathBuffer = new StringBuffer();

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

Merchant merchant = (Merchant) request.getSession().getAttribute("merchant");
String userPath = "userDefault";
if (merchant != null) {
userPath = String.valueOf(merchant.getId());
}
userFilesPathBuffer.append(userPath);

return userFilesPathBuffer.toString();

}
}



当然,这次主要是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网上的很多,我就不细说了
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值