mybatis的xml常用标签的用法示例
01 if标签
<if test="param.phone != null and param.phone != ''">
AND mobile = #{param.phone}
</if>
02 foreach标签
<foreach collection="param.ids" index="index" item="item"
separator="," open="(" close=")">
#{item}
</foreach>
03 choose when标签
s.call_num
<choose>
<when test="param.callNumOps ==0 ">
<![CDATA[ > ]]>
</when>
<when test="param.callNumOps ==1 ">
<![CDATA[ >= ]]>
</when>
<when test="param.callNumOps ==2 ">
<![CDATA[ < ]]>
</when>
<when test="param.callNumOps ==3 ">
<![CDATA[ <= ]]>
</when>
<when test="param.callNumOps ==4 ">
<![CDATA[ = ]]>
</when>
<otherwise>
<![CDATA[ = ]]>
</otherwise>
</choose>
#{param.callNum}
防转义
转义的字符有 <
<![CDATA[ AND created_time <= #{param.createdTimeMax} ]]>