mybatis `if test` 标签判断字符串

错误:

这里mentorTypeString类型,运行后发现不生效。后尝试将'1'改为双引号,问题解决。

java 复制代码
<if test="mentorType != null and mentorType!='' and mentorType=='1' ">
       AND u.student_mentor_id = #{searchValue}
</if>

正确写法:

java 复制代码
<if test='mentorType != null and mentorType!="" and mentorType=="1" '>
       AND u.student_mentor_id = #{searchValue}
</if>

搜了一下,不少人遇到这个问题,并提供了另一种解决方法:用单引号时这样写

java 复制代码
'1'.toString()

鉴于能力有限,不能进一步深入研究mybatis <if test>判断原理。下图来自文心一言

相关推荐
HerayChen2 小时前
HbuilderX 内存溢出报错
java·大数据·linux
程序员小白条3 小时前
0经验如何找实习?
java·开发语言·数据结构·数据库·链表
小马爱打代码3 小时前
Spring AI:搭建自定义 MCP Server:获取 QQ 信息
java·人工智能·spring
郭涤生3 小时前
QT 架构笔记
java·数据库·系统架构
韩立学长3 小时前
基于Springboot流浪动物领养网站0kh2iyb4(程序、源码、数据库、调试部署方案及开发环境)系统界面展示及获取方式置于文档末尾,可供参考。
数据库·spring boot·后端
daidaidaiyu3 小时前
基于LangGraph开发复杂智能体学习一则
java·ai
Moment3 小时前
从美团全栈化看 AI 冲击:前端转全栈,是自救还是必然 🤔🤔🤔
前端·后端·面试
小小8程序员4 小时前
STL 库(C++ Standard Template Library)全面介绍
java·开发语言·c++
a努力。4 小时前
Redis Java 开发系列#2 数据结构
java·数据结构·redis
R.lin4 小时前
windows MySQL解压版安装教程
windows·mysql·adb