使用set標籤可以將動態的配置 SET 關鍵字,並剔除追加到條件末尾的任何不相關的逗號
目前最長見的應用場景就是 update的時候 if 和set 配合使用,別的功能不知道了
<update id="dynamicSetTest" parameterType="Blog">
update t_blog
<set>
<if test="title != null">
title = #{title},
</if>
<if test="content != null">
content = #{content},
</if>
<if test="owner != null">
owner = #{owner}
</if>
</set>
where id = #{id}
</update>