diff --git a/diboot-file-starter/src/main/java/com/diboot/file/controller/BaseExcelFileController.java b/diboot-file-starter/src/main/java/com/diboot/file/controller/BaseExcelFileController.java index a6b30ad..c728763 100644 --- a/diboot-file-starter/src/main/java/com/diboot/file/controller/BaseExcelFileController.java +++ b/diboot-file-starter/src/main/java/com/diboot/file/controller/BaseExcelFileController.java @@ -178,6 +178,10 @@ public abstract class BaseExcelFileController extends BaseFileController { } throw e; } + //最后拦截,如果数据异常在listener中未被拦截抛出异常,此处进行处理 + if (V.notEmpty(listener.getErrorMsgs())) { + throw new BusinessException(Status.FAIL_VALIDATION, S.join(listener.getErrorMsgs(), "; ")); + } // 绑定属性到model dataMap.put("header", listener.getFieldHeaders()); dataMap.put(ORIGIN_FILE_NAME, originFileName); @@ -209,6 +213,10 @@ public abstract class BaseExcelFileController extends BaseFileController { } throw e; } + //最后拦截,如果数据异常在listener中未被拦截抛出异常,此处进行处理 + if (V.notEmpty(listener.getErrorMsgs())) { + throw new BusinessException(Status.FAIL_VALIDATION, S.join(listener.getErrorMsgs(), "; ")); + } return listener.getDataList().size(); }