Mybatis传入逗号隔开的字符串处理
作者:
MaJiT | 来源:发表于
2020-02-05 16:15 被阅读0次
通过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>
本文标题:Mybatis传入逗号隔开的字符串处理
本文链接:https://www.haomeiwen.com/subject/ouvsxhtx.html
网友评论