mybatis 中insert语句报如下错误: Incorrect integer value: '' for column 'pic_len' at row 1

来源:互联网 发布:cocos2dx mac 编辑:程序博客网 时间:2024/05/19 15:20

使用mybatis插入数据:

1)数据库表结构中pic_len是一个int(2)类型的字段;

2)springmvc的controller从前端表单获取到pic_len表单项数据pLen,加入前端表单未输入值,这时pLen输出为空字符串“”;

3)使用mybatis插入数据  insert into ....pic_len=#{pLen},... 这时,就会报错:Incorrect integer value: '' for column 'pic_len' at row 1


解决办法:网上说是mysql5版本问题,需要修改sql_mode,将其修改为sql-mode="NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION",但我尝试后仍然有问题。索性,使用下面方法解决:

在mybatis中,传值的时候把“”改成了null:

paramMap.put("picLen", null);

0 0
原创粉丝点击