使用trim标签 suffixOverrides的作用是最后一条去掉逗号 if个就是条件判断
<update id="updateUser" parameterType="com.zy.entity.User">
UPDATE user
<trim prefix="set" suffixOverrides=",">
<if test="userName!=null">userName=#{userName},</if>
<if test="nickName!=null">nickName=#{nickName},</if>
<if test="avatar!=null">avatar=#{avatar},</if>
<if test="email!=null">email=#{email},</if>
<if test="age!=null">age=#{age},</if>
<if test="introduction!=null">introduction=#{introduction},</if>
</trim>
WHERE id=#{id}
</update>