mybaitis标签中没有else标签 不知为何这么设计,
<sql id="getAllWhere">
<if test="condition != null">
<if test="condition.type >=10"> and g.type > #{condition.type} </if>
<if test="condition.type gt 10"> and g.type > #{condition.type} </if>
</if>
<if test="sort != null "> <!-- 时间排序 -->
<if test="order != null"> order by #{sort} #{order} </if>
<if test="order == null"> order by #{sort} desc </if>
</if>
</sql>
<if test="condition.type gt 10"> and g.type > #{condition.type} </if>
上面的小于符号必须转议,否则不会识别 报错。
本文探讨了MyBatis中的条件查询实现方式,特别是在使用if标签进行复杂逻辑判断时的技巧,包括如何处理不等式条件及排序需求,并强调了特殊字符的转义规则。
1794

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



