美文网首页
mybatis 字符串判断的坑

mybatis 字符串判断的坑

作者: 念䋛 | 来源:发表于2021-09-16 13:57 被阅读0次

mybatis的if标签在实际项目中经常会用到,当判断字符串的时候,有这么一个坑

正确
<if test="name=='zhangsan'.toString()">
<if test = 'name== "zhangsan" '>
错误
<if test="name=='zhangsan' ">
这样写是把 zhangsan 作为char类型判断,string和char类型判断是不会相等的

相关文章

网友评论

      本文标题:mybatis 字符串判断的坑

      本文链接:https://www.haomeiwen.com/subject/wqmrgltx.html