MyBatis 中if 标签 判断字符串不生效

mac2024-06-17  39

今天遇到if 标签判断字符串不生效,导致查询结果错误:

异常sql 的mapper 文件:

<if test="isBound != null and isBound !='' and isBound == '1'"> and box_sid is not null </if> <if test="isBound != null and isBound !='' and isBound == '2'"> and box_sid is null </if>

正确sql 的mapper 文件

<if test="isBound != null and isBound !='' and isBound == '1'.toString()"> and box_sid is not null </if> <if test="isBound != null and isBound !='' and isBound == '2'.toString()"> and box_sid is null </if>

 

最新回复(0)