mybatis:提示错误java.lang.NumberFormatException: For input string

  • Post author:
  • Post category:java


在mybatis的if判断中,遇到需要验证是否等于某字符串的情况,如果直接用==会出现java.lang.NumberFormatException的报错提示。

--- 会报错
<if test="is_printed !=null and is_printed =='是' ">
   and COALESCE(invoice_no,'') !=''
</if>

解决方案

将is_printed ==’是’ 改成 is_printed eq ‘是’.toString() 即可。

		<if test="is_printed !=null and is_printed eq '是'.toString() ">
			and COALESCE(invoice_no,'') !=''
		</if>
		<if test="is_printed !=null and is_printed eq '否'.toString() ">
			and COALESCE(invoice_no,'') =''
		</if>



版权声明:本文为quan278905570原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。