`

mybatis --mapper配置文件中大于小于怎么处理

 
阅读更多
http://blog.csdn.net/nich002/article/details/17756439
别人也有弄过, 不过有点零碎, 自己整理下.
在mybatis 的mapper配置文件sql语句中, 有时用到 大于, 小于等等的比较, 直接写在里面就被当做标签的开头来处理了, 所以不可.现在又2种解决方法:

一, 用<![CDATA[   ]]>标识,例如:
<if test="menu.authority != null">  
    <![CDATA[ and authority < #{menu.authority}]]>  
</if>  

其中不但能用大于'>', 小于'<',          小于等于'<=', 大于等于'>=' 也是可以的.

二, 转义, 例如:
<if test="menu.authority != null">  
    and authority &lt; #{menu.authority}  
</if>  

如此这般......
同样可以可以和等号'='一起来使用, 来表示大于等于, 小于等于等.如
<if test="menu.authority != null">  
    and authority &gt;= #{menu.authority}  
</if>
 
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics