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 ...
随机推荐
- 数据库转换Mysql-Oracle之建表语句
Mysql建库语句(导出的): DROP TABLE IF EXISTS `tablename`; CREATE TABLE `tablename` ( `C_DI_CDE` varchar(40) ...
- CR LF CR/LF
CR:Carriage Return,对应ASCII中转义字符 '\r' (0x0D),表示回车LF:Line Feed,对应ASCII中转义字符 '\n' (0x0A),表示换行CRLF:Carri ...
- Python使用正则表达式(Regular Expression)超详细
一.导入re库 python使用正则表达式要导入re库. import re在re库中.正则表达式通常被用来检索查找.替换那些符合某个模式(规则)的文本.ps:另外很多人在学习Python的过程中,往 ...
- 119、Java中String类之通过isEmpty判断是否为空字符串
01.代码如下: package TIANPAN; /** * 此处为文档注释 * * @author 田攀 微信382477247 */ public class TestDemo { public ...
- Python 爬取 北京市政府首都之窗信件列表-[信息展示]
日期:2020.01.25 博客期:133 星期六 [代码说明,如果要使用此页代码,必须在本博客页面评论区给予说明] //博客总体说明 1.准备工作 2.爬取工作 3.数据处理 4.信息展示(本期博客 ...
- UGUI 特效怎样在UI上裁剪
刚好碰到有人问怎样把粒子特效放到 UI 上并且能正确被 Mask 裁剪, 首先想到给粒子效果的 Shader 添加模板模仿一般 UI 的模板方式, 应该就能正确裁剪了吧, 不过没那么简单, 我们看到在 ...
- 吴裕雄 Bootstrap 前端框架开发——Bootstrap 表单
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...
- eclipse不能启动,An internal error occurred during: "reload maven project".
An internal error occurred during: "reload maven project". 这个错误是因为项目已经关闭,导致 导致此问题的原因是Sprin ...
- IOS导航器 + 表控制器 常用功能函数/属性
1. 设置标题栏(顶部)颜色 在表控制器中 e.g -(void)viewDidLoad中添加 self.navigationController.navigationBar.barTintColor ...
- java 之word转html
jar包 链接: https://pan.baidu.com/s/13o2CZTwM-Igx6wcoyEu_ug 密码: n95q package com.bistu.service; import ...