您的位置:首页 > 其它

ckeditor和ckfinder结合使用时问题的解决办法

2015-06-26 20:02 393 查看
ckeditor是很流行的的文本编辑器,ckfinder是它的补充,为ckeditor提供图片、flash上传功能,在使用它们的过程中,遇到一些问题,记录下来。

1、当上传图片名称是中文时,上传失败。解决办法:在tomcat的配置文件server.xml中,在Connector组件处,加上 URIEncoding="utf-8"。

2、重复上传同一文件,报错,解决办法,修改FileUploadCommand.java类,在execute方法开始出加上errorCode=0;如下所示:

@Override
public void execute(final OutputStream out) throws ConnectorException {
if (configuration.isDebugMode() && this.exception != null) {
throw new ConnectorException(this.errorCode, this.exception);
}
try {
errorCode=0;
String errorMsg = (this.errorCode == 0) ? "" : ErrorUtils.getInstance().getErrorMsgByLangAndCode(this.langCode,
this.errorCode, this.configuration);
errorMsg = errorMsg.replaceAll("%1", Matcher.quoteReplacement(this.newFileName));
String path = "";

if (!uploaded) {
this.newFileName = "";
this.currentFolder = "";
} else {
path = configuration.getTypes().get(type).getUrl()
+ this.currentFolder;
}

if (this.responseType != null && this.responseType.equals("txt")) {
out.write((this.newFileName + "|" + errorMsg).getBytes("UTF-8"));
} else {
out.write("<script type=\"text/javascript\">".getBytes("UTF-8"));
if (checkFuncNum()) {
handleOnUploadCompleteCallFuncResponse(out, errorMsg, path);
} else {
handleOnUploadCompleteResponse(out, errorMsg);
}
out.write("</script>".getBytes("UTF-8"));
}

} catch (IOException e) {
throw new ConnectorException(
Constants.Errors.CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED, e);
}

}


阅读源代码可以发现,当文件存在时,系统会给这个赋值201,导致出错。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: