JFinal

登录 注册

jifnal catch异常后为为什么不能setAttr

try {

List<UploadFile> attachList = getFiles("notice", 100 * 1024 * 1024, "utf-8");

for (int i = 0; i < attachList.size(); i++) {

String imagename = "";

String filename = attachList.get(i).getOriginalFileName();

String suffix = filename.substring(filename.indexOf("."), filename.length());

String fileMd5 = MD5

.getMD5Str(filename.substring(0, filename.indexOf(".")) + "/" + new Date().getTime());

imagename = fileMd5 + suffix;

attachList.get(i).getFile().renameTo(new File(attachList.get(i).getUploadPath(), imagename));

Attachment attachment = new Attachment();

attachment.set("type", 0);

attachment.set("title", filename);

attachment.set("path", imagename);

attachment.set("download", 0);

if (noticeService.saveAttachment(attachment)) {

list.add(attachment);

} else {

setAttr("result", ResultSign.Fail.getState());

setAttr("msg", "保存失败");

}

}

setAttr("result", ResultSign.Success.getState());

setAttr("msg", "添加附件成功");

setAttr("AttachmentList", new AttachmentList(list));

} catch (Exception e) {

e.printStackTrace();

setAttr("result", 101);

setAttr("msg", "附件大小超出规定范围(0-100M)");

}


评论