mybatis 参数格式异常-- Error querying database. Cause: java.lang.NumberFormatException: For input string

mybatis中 <if></if>标签中进行判断时,如果传入的时字符格式和数字进行判断需要将数字进行转译,否则默认是数字和数字进行比较,这是就会出现参数格式异常
如<if test="department != 0 and department != null" > 中不对0进行转译就会出现这个错误
可以将0用“”引起来,外面的“”改编成‘’或者将0变成‘0’.toString(),如下所示:(将0直接以‘’处理就会变成String格式和char格式进行比较,也会出现同类错误)
<if test=‘department != “0” and department != null’ >
或者
<if test="department != ‘0’.toString() and department != null" >

猜你喜欢

转载自www.cnblogs.com/sudoit/p/10756988.html