@At("/uploadZcpdMx")
@AdaptBy(type = UploadAdaptor.class, args = { "ioc:myUpload" })
@Ok("json")
public Object uploadZcpdMx(@Param("Fdata") TempFile tf,@Param("zcdlId") String zcdlId, @Param("title") String title) {
BaseResultMap ret = new BaseResultMap(true, "上传成功.");// 如果不发生异常的话,返回此消息
try {
cwZcpdMxService.uploadFile(tf,zcdlId,title);
ret.setOk(true);
} catch (Exception e) {
logError(e);// 第一步,先打印异常,log4j记录日志
ret.setOk(false);// 第二步,设置返回结果为false
ret.setMessage(WarningException.getExceptionMsg(e));// 第三步,返回给用户错误消息,过滤掉底层异常消息(例如SQLException,FileNotFoundException)
}
return ret;
}
控制台信息:
2017-12-22 10:37:32 [DEBUG] org.nutz.mvc.impl.UrlMappingImpl.get(UrlMappingImpl.java:101) - Found mapping for [POST] path=/cw/cwZcpdMx/uploadZcpdMx : CwDisbursementVoucherDetailAction.uploadZcpdMx(CwDisbursementVoucherDetailAction.java:79)
2017-12-22 10:37:32 [DEBUG] org.nutz.ioc.impl.NutIoc.get(NutIoc.java:157) - Get 'cwDisbursementVoucherDetailAction'<class com.fzzl.hrp.cw.zcpd.controller.CwDisbursementVoucherDetailAction>