Mybatis传入逗号隔开的字符串处理

2020-02-05  本文已影响0人  MaJiT

通过myBatis自带功能foreach,直接把逗号分隔的字符串传到mapper.xml即可,后台不用过多操作。

<if test="pd.quarter!= null and pd.quarter != ''">
            <if test="pd.selectQuarter!= null and pd.selectQuarter != ''">
                and quarter in
                <foreach item="item" index="index" collection="pd.selectQuarter.split(',')"  open="(" separator="," close=")">
                    '${item}'
                </foreach>
            </if>
            <if test="pd.selectQuarter== null or pd.selectQuarter == ''">
                and quarter = #{pd.quarter}
            </if>
        </if>
上一篇 下一篇

猜你喜欢

热点阅读