mybatis 报错:Cause: java.lang.NumberFormatException: For input string: ““
mybatis 报错:Cause: java.lang.NumberFormatException: For input string: “”
问题描述
我使用的mybatis版本是3.5.5。
使用mybatis动态SQL进行模糊查询,if条件判断时,报出数字格式错误。
//Mapper.xml源代码<select id="selectByCondition" resultMap="brandResultMap">select *from tb_brandwherestatus = #{status}<if test="companyName != null and companyName != ' '">and company_name like #{companyName}</if><if test="brandName != null and brandName != ' '">and brand_name like #{brandName}</if></select>
org.apache.ibatis.exceptions.PersistenceException:
### Error querying database. Cause: java.lang.NumberFormatException: For input string: "%华为%"
### Cause: java.lang.NumberFormatException: For input string: "%华为%"... moreat org.apache.ibatis.scripting.xmltags.DynamicSqlSource.getBoundSql(DynamicSqlSource.java:39)at org.apache.ibatis.mapping.MappedStatement.getBoundSql(MappedStatement.java:305)at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:87)at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:147)... 32 moreProcess finished with exit code -1
原因分析:
问题的原因在于mybiatis是基于OGNL语法,在解析单引号+单字符 ‘Y’ 的解析时会默认时char类型,单引号+多字符 ‘AA’ 或者双引号+单字符 “A” 解析为String类型。
解决方案:
把单引号和双引号的位置互换即可。
<if test='companyName != null and companyName != " "'>and company_name like #{companyName}</if>
mybatis 报错:Cause: java.lang.NumberFormatException: For input string: ““相关推荐
- 访问swagger/Knife4j 接口文档报错:java.lang.NumberFormatException: For input string: ““
目录 问题描述 解决过程 问题描述 报异常如下:java.lang.NumberFormatException: For input string: "" 虽然不影响使用,但是每次 ...
- 关于Swagger报错java.lang.NumberFormatException: For input string: 的总结
关于Swagger报错java.lang.NumberFormatException: For input string: ""的总结 1 为什么会报错? 2 如何排错? 3 哪种 ...
- Mybatis报错: Error querying database. Cause: java.lang.NumberFormatException: For input string: “A“
报错信息:Error querying database. Cause: java.lang.NumberFormatException: For input string: "A" ...
- mybatis 报错:Cause: java.lang.NumberFormatException: For input string
Cause: java.lang.NumberFormatException: For input string 异常提示 异常来源 异常解决 异常提示 Error querying database ...
- swagger报错 java.lang.NumberFormatException: For input string: ““
项目中集成Swagger,每次刷新页面,都给我报一个java.lang.NumberFormatException: For input string: ""的错误,真的是犯强迫症 ...
- 线上flink任务重启报错(Hadoop问题)java.lang.NumberFormatException: For input string: “30s“
线上Flink任务重启时,提交任务失败,具体报错如下: 2021-12-31 18:09:19 java.lang.NumberFormatException: For input string: & ...
- 关于java.lang.NumberFormatException: For input string:${redis.maxIdle}的报错
项目通用文件配置目录 reids配置文件 <?xml version="1.0" encoding="UTF-8"?> <beans xmln ...
- java.lang.NumberFormatException: For input string: F
在通过myBatis执行sql时,报错: java.lang.NumberFormatException: For input string: "F" xml中sql内容为: &l ...
- Caused by: java.lang.NumberFormatException: For input string: “?2130969371“
Caused by: java.lang.NumberFormatException: For input string: "?2130969371" 题记报错. 上结论:&quo ...
最新文章
- 个人博客开发-01-nodeJs项目搭建
- python大数据结课报告_2020知到大数据分析的PYTHON基础结课答案
- 基于Reddsion分布式的锁实现
- Pentest Box -windows平台的linux bash,集成了很多测试工具
- wider face data 在 faster rcnn 上的实践记录(caffe)
- 科技行业风投日趋谨慎:VR、机器学习和汽车值得关注
- 女人跳槽:最重要的是你的独立,你的快乐
- react router官方文档_阿里开源可插拔 React 跨端框架 UmiJS
- linux 系统调用_Linux系统调用初学者指南
- 结构变量的定义和引用
- DriverMessageBean配置详解
- sitecore系统教程之体验编辑器
- 软件加密狗破解思路和防破解的博弈之路
- python 怎么将数字转大写_python中如何将货币数字转化成汉字大写
- Arcgis进行人口密度计算
- 学生信息管理系统python面向对象_Python学员管理系统【面向对象实现】
- 用Verilog编写“数显LED的亮度控制电路”
- 开发常用镜像站 - 阿里云镜像站
- P1234 小A的口头禅题解
- TLV自定义通信协议的编码和解析
热门文章
- 2022年稀释制冷机全球市场规模达2.11亿美元,2028年有望出现突破点
- 基于php的网络投票在线投票系统
- 金蝶KIS K3提示当前使用的功能与其他用户有冲突的解决办法
- 液晶屏接口LVDS接口与MIPI DSI接口区别
- 大数据“拉网捕鼠” 博时基金马乐深圳受审
- 二维码图片转换成矩阵
- NanoPi M1 Plus OpenWRT挂载NFS rootfs
- Logstash [logstash.outputs.elasticsearch][main] retrying failed action with response code: 403
- Java基础入门(持续更新)
- 中科蓝讯蓝牙方案开发--调通话汇总