问:<if test="name!=null">
where name like concat('%',#{name},'%')
</if> sql
答:根据test中条件是否成立断定<if>内语句是否生效数组
问:<where>
<if test="name!=null">
and name like concat('%',#{name},'%')
</if>
<if test="price!=null and price!=0">
and price > #{price}
</if>
</where> ide
答:对象
问: <update id="updateProduct" parameterType="Product" >
update product_
<set>
<if test="name != null">name=#{name},</if>
<if test="price != null">price=#{price}</if>
</set>
where id=#{id}
</update>索引
答:与where标签相似的,在update语句里也会碰到多个字段相关的问题。 在这种状况下,就能够使用set标签字符串
问:<trim prefix="WHERE" prefixOverrides="AND |OR "> ... </trim>与<trim prefix="SET" suffixOverrides=","> ... </trim>get
答:it
问:<foreach item="item" index="index" collection="list" open="(" separator="," close=")"> #{item} </foreach>io
答:test
问:<bind name="pattern" value="'%' + _parameter.getTitle() + '%'" /> SELECT * FROM BLOG WHERE title LIKE #{pattern}
答:bind 元素能够从 OGNL 表达式中建立一个变量并将其绑定到上下文,至关于建立了一个变量来存放字符串