Mybatis if语句对比string时提示NumberFormatException

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接: https://blog.csdn.net/ldaokun2006/article/details/50780430

是OGNL的语法问题,这里'Y'将被认为是char类型的数据,但是'YY'或者“Y”将被认为是String类型的数据,解决方案如下所示:

1:将代码改为test="param eq 'Y'.toString()"

2:将代码改为test="name == "Y""

3:将代码改为test='index == "Y"'

4:将代码改为test="param == 'Y'.toString()"

当对象的映射文件及对应的属性如下编写时,<result column="IF_SHIELD" property="ifShield" jdbcType="VARCHAR" /> privateString ifShield;

<if test="ifShield==1">是没问题的(并且数字是全部没问题的,无论是小数还是整数是正数还是负数),不过这样编写<result column="IF_SHIELD" property="ifShield" jdbcType="CHAR" /> private String ifShield;

<if test="ifShield==1">就是有问题的。

猜你喜欢

转载自blog.csdn.net/ldaokun2006/article/details/50780430