mybaties if 比较字符串内容

来源:互联网 发布:客户管理crm软件 编辑:程序博客网 时间:2024/06/12 01:29

法1:

正确:

<if test='activityBean.searchForce=="N" '>

错误:

<if test="activityBean.searchForce=='N' ">

因为java是强类型语言,单引号表示char类型,只能赋给一个字符给char类型,

而双引号则表示String类型


法2:


<if test="isExpired=='Y'">
and msg.expire_time &lt; now()

</if>

会报NumberFormatException,这样就可以了。

<if test="isExpired=='Y'.toString()">
and msg.expire_time &lt; now()
</if>



法3:


<if test='verityFailureMark eq "1"'>

theaterLocation='1'
</if>
<if test='verityFailureMark eq "2"'>
ONELINELOCATION='1'
</if>



0 0
原创粉丝点击