From 4a63c0ba7f52f83178650f0b2dd3f5793176618e Mon Sep 17 00:00:00 2001 From: "han\\hanst" Date: Thu, 8 Oct 2026 10:14:47 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AD=98=E5=82=A8=E8=BF=87=E7=A8=8B=E7=9A=84?= =?UTF-8?q?=20params=20=E6=98=AF=20List=E3=80=82MyBatis=20=E5=AF=B9?= =?UTF-8?q?=E9=9B=86=E5=90=88/=E6=95=B0=E7=BB=84=E8=B0=83=E7=94=A8=20hasSe?= =?UTF-8?q?tter=20=E4=BC=9A=E6=8A=9B=20UnsupportedOperationException?= =?UTF-8?q?=EF=BC=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/gaotao/config/MybatisLoginUserInterceptor.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/com/gaotao/config/MybatisLoginUserInterceptor.java b/src/main/java/com/gaotao/config/MybatisLoginUserInterceptor.java index c143a59d..210b3cc7 100644 --- a/src/main/java/com/gaotao/config/MybatisLoginUserInterceptor.java +++ b/src/main/java/com/gaotao/config/MybatisLoginUserInterceptor.java @@ -20,6 +20,7 @@ import org.springframework.core.annotation.Order; import org.springframework.stereotype.Component; import java.sql.Connection; +import java.util.Collection; import java.util.Map; import java.util.Properties; @@ -89,6 +90,11 @@ public class MybatisLoginUserInterceptor implements Interceptor { } return; } + // 存储过程的 params 是 List。MyBatis 对集合/数组调用 hasSetter 会抛 UnsupportedOperationException, + // 请求在 exec 之前就失败。登录名也不能塞进过程实参,否则会多出一个参数。 + if (bean instanceof Collection || bean.getClass().isArray()) { + return; + } MetaObject metaObject = SystemMetaObject.forObject(bean); if (metaObject.hasSetter(LOGIN_USER_PARAM) && metaObject.getValue(LOGIN_USER_PARAM) == null) { metaObject.setValue(LOGIN_USER_PARAM, loginUserName);