1) <where> 能自动去掉where最前面and或者or
<select id="find" parameterType="map" resultMap="personRM">
select <include refid="cols"/> from person
<where>
<if test="name!=null">and user_name like #{name}</if>
<if test="age!=null">and age=#{age}</if>
</where>
</select>
2) <set>自动删除最后一个逗号
<set>
<if test="name!=null">user_name=#{name},</if>
<if test="age!=null">age=#{age},</if>
<if test="remark!=null">remark=#{remark},</if>
</set>
3) <foreach>
<foreach collection="ids" item="id" open="(" close=")" separator=",">
#{id}
</foreach>
where id in
(
<foreach collection="array" item="id" separator=",">
#{id}
</foreach>
)