<update id="update" parameterType="map"> update t_role <set> <if test="name != null and name !=‘‘"> name=#{name}, </if> <if test="msg != null and msg !=‘‘"> msg=#{msg}, </if> <if test="type != null and type !=‘‘"> type=#{type}, </if> <if test="creator_id != null and creator_id !=‘‘"> creator_id=#{creator_id}, </if> <if test="level != null and level !=‘‘"> level=#{level} </if>
</set>
where id=#{id} </update>
使用 <set></set>可以智能去掉最后一个逗号,十分方便!