kindeditor 文件上传 java_java kindeditor图片上传 json返回值的问题,要让kindeditor收到成功的信息...

在处理KindEditor的文件上传时,遇到Java后台创建目录并保存文件的场景。通过判断父目录是否存在并创建,然后使用FileUtils复制文件到目标位置。成功上传后,将错误码设为0,并构建包含URL的JSON对象返回给KindEditor。在出现异常时,设置错误码为1并返回错误信息。
摘要由CSDN通过智能技术生成

if(!savefile.getParentFile().exists()){savefile.getParentFile().mkdirs();try{FileUtils.copyFile(imgFile,savefile);map.put("error",0);map.put("url",savefile);JSONObjectjso...

if (!savefile.getParentFile().exists()) {

savefile.getParentFile().mkdirs();

try {

FileUtils.copyFile(imgFile, savefile);

map.put("error", 0);

map.put("url", savefile);

JSONObject json = JSONObject.fromObject(map);

response.getOutputStream().print(json.toString());

} catch (IOException e) {

e.printStackTrace();

}

} else {

try {

FileUtils.copyFile(imgFile, savefile);

map.put("url", savefile);

map.put("error", 0);

JSONObject json = JSONObject.fromObject(map);

System.out.println(json);

response.getOutputStream().print(json.toString());

} catch (IOException e) {

} else {

map.put("error", 1);

map.put("message", "上传失败");

JSONObject json = JSONObject.fromObject(map);

try {

response.getOutputStream().print(json.toString());

} catch {

DeBug运行到JSONObject json = JSONObject.fromObject(map);就会进入DefaultActionInvocation.class,

kindeditor报的错误信息

type Exception report

message There is a cycle in the hierarchy!

description The server encountered an internal error that prevented it from fulfilling this request.

exception

net.sf.json.JSONException: There is a cycle in the hierarchy!

展开

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值