通过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>
网友评论