在写一个功能的时候,有一个参数是判断是否跟指定字符串相等,代码如下:
<if test="sqzt != null and sqzt != ''"> <choose> <when test="sqzt == '1'"> AND e.user_id is not null AND e.user_id != '' </when> <when test="sqzt == '0'"> AND e.user_id is null OR e.user_id = '' </when> </choose> </if>
结果发现判断条件无法成立,后来查阅了相关资料,需要把test里面的双引号,改成单引号,如下:
<if test="sqzt != null and sqzt != ''"> <choose> <when test='sqzt == "1"'> AND e.user_id is not null AND e.user_id != '' </when> <when test='sqzt == "0"'> AND e.user_id is null OR e.user_id = '' </when> </choose> </if>