java.lang.NumberFormatException: For input string: "F"
在通过myBatis执行sql时,报错: java.lang.NumberFormatException: For input string: "F"
xml中sql内容为:
<if test="myKey == 'P' ">
and `Field1` = #{fieldname}
</if>
其中 fieldname的值为 F, 没明白会报 NumberFormatException, 明明是字符型,后一步步调试代码到:
\.m2\repository\org\mybatis\mybatis\3.5.2\mybatis-3.5.2.jar!\org\apache\ibatis\ognl\ASTNotEq.class
报错的代码为(OgnlOps.equal):
protected Object getValueBody(OgnlContext context, Object source) throws OgnlException {
Object v1 = this._children[0].getValue(context, source);
Object v2 = this._children[1].getValue(context, source);
return OgnlOps.equal(v1, v2) ? Boolean.FALSE : Boolean.TRUE;
}
v1,v2值分别为下图:

v2的值成了P,得到v2的类型为:

没明白,后边试着把 <if test="myKey == 'P' "> 调整为: <if test="myKey == 'PP' "> 多加了一个P
这时v2的类型就为String了,估计MyBatis如果发现为单字符,都统一处理为了 Character, 试着调整为: <if test="myKey == "P" "> 单引号改为双引号(或加转义符),都不行
试着转换单双引号为(test里外包的将双引号改为单引号, P字符调整为双引号):
<if test='myKey == "P" '>
and `Field1` = #{fieldname}
</if>
再试,功能正常
java.lang.NumberFormatException: For input string: "F"的更多相关文章
- Mybatis异常:java.lang.NumberFormatException: For input string: "S"
MyBatis异常日志如下: Caused by: java.lang.NumberFormatException: For input string: "S" at sun.mi ...
- java.lang.NumberFormatException: For input string: "1608020001 " 错误
错误: java.lang.NumberFormatException: For input string: "1608020001 " at java.lang.Numbe ...
- java.lang.NumberFormatException: For input string: "Y"
nested exception is org.apache.ibatis.exceptions.PersistenceException: ### Error querying database. ...
- mybatis 报错:Caused by: java.lang.NumberFormatException: For input string
mybatis的if标签之前总是使用是否为空,今天要用到字符串比较的时候遇到了困难,倒腾半天,才在一个论坛上找到解决方法.笔记一下,如下: 转自:https://code.google.com/p/m ...
- java.lang.NumberFormatException: For input string:"filesId"
做项目时候,页面获取出现了这个问题.找了好久一直以为是我字段或者是数据库字段问题导致引起的. 最后才发现是 struts2中jsp我写错了一个参数,一直导致报错.后来改了就好了. 当大家遇到这个问题的 ...
- 解决java.lang.NumberFormatException: For input string: "id"
今天,项目突然报"java.lang.NumberFormatException:For input string:"id"",项目框架是spring,spri ...
- MyBatis报错:Caused by: java.lang.NumberFormatException: For input string: "XX"
<select id="sltTreatment" resultType="com.vitaminmd.sunny.core.bo.Treatment"& ...
- Caused by: java.lang.NumberFormatException: For input string: "18446744073709551615"
问题:Caused by: java.lang.NumberFormatException: For input string: "18446744073709551615" 原因 ...
- Redis集群环境使用的是redis4.0.x的版本,在用java客户端jedisCluster启动集群做数据处理时报java.lang.NumberFormatException: For input string: "7003@17003"问题解决
java.lang.NumberFormatException: For input string: "7003@17003" at java.lang.NumberFormatE ...
随机推荐
- InnoDB中一棵B+树能存多少行数据
https://www.jianshu.com/p/3578beed5a68 https://www.cnblogs.com/tongongV/p/10952102.html InnoDB 存储引擎最 ...
- 跳转连接转base64
//配置H5连接 @Value("${h5.domain}") private String h5Domain; // 校验商家端权限 public String checkSta ...
- MCM(矩阵链乘法)
这是<算法导论>动态规划中的一个问题.问题简述如下:我们在求解矩阵相乘时通常会有一个最优括号方案来对矩阵进行顺序相乘,这样会减少大量的计算时间. 我们知道矩阵A.B相乘,只能是当矩阵A的列 ...
- java中读取文本文件的时候@Test方法中没有中文乱码,但是@Controller中却有中文乱码
今天遇到了一个非常牛逼的BUG,在@Test标注的测试类中没有中文乱码,但是访问@Controller标注的接口却报中文乱码,找了一系列资料以及各种尝试之后,发现是因为eclipse编辑工具字符编码的 ...
- 手搓SSM
相关资料,网上的资料很多,但是文章看不懂,看别人写好的代码比较好理解 ssm-example mysssm 整个流程和原理 一个入口类,入口类需要在tomcat启动的时候执行 通过扫描文件加把文件取出 ...
- windows 批量杀进程 类似pkill
轉:http://blog.sina.com.cn/s/blog_55fb522f0100whki.html 1.开始-运行(或win+R),输入cmd,打开命令行模式: 2.输入tasklist,可 ...
- css属性选择器: | 与 ~
[attribute|=value] 选择器用于选取带有以指定值开头的属性值的元素. 注释:该值必须是整个单词,指属性的值是一个完整的单词,并未被中断.如“eng”."img".& ...
- Centos7 更新配置为阿里源步骤
一.yum更换配置源过程 1.备份原有的.repo源文件 首先需要将之前的源进行备份(一般重要的配置文件都需要有备份的意识) # 进入源配置目录 cd /etc/yum.repos.d # 创建备份文 ...
- 洛谷 P1263 宫廷守卫
被这道题折腾了 \(2\) 个小时. 按照题意,每个守卫的上下左右四个方向上应当都是墙,而不能出现其他的守卫. 如图是一个合法的放置方案.每个守卫四个方向上都是墙(包括宫廷外墙). 如图是一个非法的放 ...
- pytorc人工神经网络Logistic regression与全连接层
//2019.10.08神经网络与全连接层1.logistics regression逻辑回归的思想是将数据利用激活函数sigmoid函数转换为0-1的概率,然后定义一定的阈值0.5,大于阈值则为一类 ...