代码如下:
@At("/upload")
@Ok("json")
@AdaptBy(type = UploadAdaptor.class, args = { "ioc:myUpload" })
public Object upload(@Param("Fdata") TempFile tf,@Param("..") Map map) {
BaseResultMap ret = new BaseResultMap(true, "上传成功!");// 如果不发生异常的话,返回此消息
try {
XtUploadFilePojo xtUploadFilePojo=(XtUploadFilePojo) xtUploadFileService.upload(tf,map);
ret.setData(xtUploadFilePojo);
} catch (Exception e) {
logError(e);// 第一步,先打印异常,log4j记录日志
ret.setOk(false);// 第二步,设置返回结果为false
ret.setMessage(WarningException.getExceptionMsg(e));// 第三步,返回给用户错误消息,过滤掉底层异常消息(例如SQLException,FileNotFoundException)
}
return ret;
}
传入的json:
{"businessTableName":"M_CUSTOMER","businessTableId":1496,"fileContentTypeName":"客户","mCustomerContract":"{"mCustomerContractbigContractTypeId":"73","companyId":2,"signDate":"2018-01-08T00:00:00","startDate":"2018-01-08T00:00:00","endDate":"2018-01-30T00:00:00","bigContractTypeId":"73"}"}
实际获取的map数据:
{businessTableName=M_CUSTOMER, businessTableId=1496, fileContentTypeName=客户, mCustomerContract={, Fdata=org.nutz.mvc.upload.TempFile@3760e1ed}
结果 mCustomerContract 里面缺失了数据.。。