mapper.xml中判断字符串
<if test="flag == 'N'">
AND cust.certificate_no NOT IN (#{idCards})
</if>
这种写法会报:org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException:
### Error querying database. Cause: java.lang.NumberFormatException: For input string: "N"
### Cause: java.lang.NumberFormatException: For input string: "N"
因为mybatis映射文件,是使用的ognl表达式,所以会把‘Y'解析为char,java是强类型的语言,不能这样写,正确写法:
<if test="flag == 'N'.toString()">
AND cust.certificate_no NOT IN (#{idCards})
</if>
或者<if test='flag == "N"'>
AND cust.certificate_no NOT IN (#{idCards})
</if>
最后
以上就是阔达大叔最近收集整理的关于mybatis中判断字符串的全部内容,更多相关mybatis中判断字符串内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复