Mybatis中如何引用类的静态常量List做foreach
静态类定义如下
/**
* @author lfm
* @date 2025/8/27
*/
public class TestClazz {
/**
* 其他入库单billType,用于数据库查询常量
*/
public static final List<Integer> STATUS_LIST = Arrays.asList(
300,301,302,400,401,402,601,602,800,810,900,1010);
}
mappler.xml中如何引用,示例如下
WHERE status IN
<foreach collection="@com.test.TestClazz@STATUS_LIST" item="item" open="(" separator="," close=")">
#{item}
</foreach>
更多使用姿势可以看这篇文章: Mybatis mapper.xml下引用静态方法、静态常量或者枚举类型 https://www.cnblogs.com/Jimc/p/16186363.html
浙公网安备 33010602011771号