解决的方法很简单
先说第一种
DAO层的函数方法
PublicUser
selectUser(String imgURL,String id);对应的Mapper.xml<sql id="updateByPo1">
<trim prefix="set" suffixOverrides=",">
<if test="_parameter!= null">
imgURL = #{imgURL},
</if>
</trim>
</sql>
update customer_account_info//表名
<include refid="updateByPo1"/>
where id = #{id}
</update>
修改后
<sql id="updateByPo1">
<trim prefix="set" suffixOverrides=",">
<if test="_parameter!= null">
imgURL = #{0},
</if>
</trim>
</sql>
update customer_account_info//表名
<include refid="updateByPo1"/>
where id = #{1}
</update>
其中,#{0}代表接收的是dao层中的第一个参数,#{1}代表dao层中第二参数,更多参数一致往后加即可。
本文介绍了一种在MyBatis中使用动态SQL时传递多个参数的方法,通过在Mapper.xml文件中调整参数引用的方式,实现了更为灵活的数据更新操作。
2万+

被折叠的 条评论
为什么被折叠?



