There is no getter for property named 'id' in 'class java.lang.Integer
There is no getter for property named 'id' in 'class java.lang.Integer
问题描述:
使用mybatis传入参数, 当参数类型是String ,Integer 等这些时。如果用他的 <if test="id != null and id != ''">标签判断该参数是否为空,通常会爆There is no getter for property named ‘id’ in ‘class java.lang.Integer异常。
解决思路:
- 在接口中该方法的参数前加上@Param(“参数名”)注解。
例如:List<String> query(@Param(value="id") Integer id);
- 我百度的时候,发现还有人这样解决,不知是否可行,一并摘录下来:
在 xml文件中应该使用_parameter来代替参数名。
例如:
<select id="query" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
<include refid="Base_Column_List" />
from t_user
where 1=1
<if test="_parameter!= null" >
and id = #{_parameter}
</if>
</select>
总结:
其实这个问题并不是很大,但是容易一不小心就误犯;所以一定要小心谨慎。
There is no getter for property named 'id' in 'class java.lang.Integer的更多相关文章
- Bug--Mybatis报错:There is no getter for property named 'id' in 'class java.lang.Integer'
Mybatis 添加@Param("")注释就可以了
- Mybatis笔记四:nested exception is org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'id' in 'class java.lang.String'
错误异常:nested exception is org.apache.ibatis.reflection.ReflectionException: There is no getter for pr ...
- 关于mybtis 使用过程中发生There is no getter for property named 'id' in class 'java.lang.String' 错误
今天在修改一个关于mybtis语句时,偶然发现的一个错误 There is no getter for property named 'id' in class 'java.lang.String' ...
- Mybatis找不到参数错误:There is no getter for property named 'categoryId' in 'class java.lang.Integer'。
Mybatis找不到参数错误:There is no getter for property named 'categoryId' in 'class java.lang.Integer'. 错误Li ...
- MyBatis查询传一个参数时报错:There is no getter for property named 'sleevetype' in 'class java.lang.Integer
用MyBatis进行查询,传入参数只有一个时(非Map)如int,报错 There is no getter for property named 'sleevetype' in 'class jav ...
- mybaits错误解决:There is no getter for property named 'id' in class 'java.lang.String'
在使用mybaitis传参数的时候,如果仅传入一个类型为String的参数,那么在 xml文件中应该使用_parameter 来代替参数名. 正确的写法: <span style="f ...
- Mybatis-There is no getter for property named 'id' in 'class java.lang.String'
<mapper namespace="cn.telchina.standard.mapper.SysOrgnMapper"> <!-- <![CDATA[s ...
- There is no getter for property named 'id' in class 'java.lang.String'
https://blog.csdn.net/u011897392/article/details/46738747 使用mybatis传入参数,如果在mappin.xml中使用<if>标签 ...
- MyBatis if test 传入一个数字进行比较报错 There is no getter for property named 'userState' in 'class java.lang.Integer'
在写MyBatis映射文件中,我要传入一个 int 类型的参数,在映射文件中用 'test' 中进行比较,我花了很长时间百度,发现都是不靠谱的方法,有把数字在比较时转成字符串用 equals 比较的. ...
随机推荐
- 锁定文件失败,打不开磁盘“D:\biehl\centos\taotao\taotao-dubbo-register\CentOS-000001.vmdk”或它所依赖的某个快照磁盘。模块“Disk”启动失败。未能启动虚拟机
1.锁定文件失败,打不开磁盘“D:\biehl\centos\taotao\taotao-dubbo-register\CentOS-000001.vmdk”或它所依赖的某个快照磁盘.模块“Disk” ...
- C 函数指针、回调函数
参考链接:https://www.runoob.com/cprogramming/c-fun-pointer-callback.html 函数指针 函数指针就是执行函数的指针,他可以像正常函数一样去调 ...
- 开发技术--Python核心技术B
开发|Python核心技术B B篇,主要介绍Python的自定义函数,匿名函数,面向对象,模块化. 由于不涉及基础的知识,我会将重难点加以解释. 前言 目前所有的文章思想格式都是:知识+情感. 知识: ...
- Vue-cli3脚手架工具快速创建一个项目
1.首先全局安装一下vue-cli3 npm install -g @vue/cli 或 yarn global add @vue/cli vue -V查看版本(这里注意V是大写哦) 2.vue cr ...
- echarts折线图上下颜色渐变样式
// 折线图let lineChart = echarts.init(document.getElementById('lineChart'));let lineOption = { title: { ...
- vue中输入框只能输入数字
方案1:增加自定义指令 自定义指令写法: directives: { numberOnly: { bind(el) { ...
- Struts2 在Action中操作数据
Servlet存储数据的方式 在Servlet中,使用ServletContext对象来存储整个WebApp的数据,ServletContext中直接存储整个WebApp的公共数据,可使用set|ge ...
- 队列(Quene)
对multiprocessing中的Quene进行演示 import multiprocessing """ 队列Quene是mutiprocessing 中 的一个类 ...
- 解决txt乱码:将windows新建txt转换成utf-8格式
场景:产品将版本发布说明发给配置管理员(我自己),我使用jenkins建的任务自动传这个版本发布说明文件(release_note.txt)到ftp以后,打开文件后发现乱码. 调试: 但是将文件另存为 ...
- 2020年第二期《python接口自动化+测试开发》课程,已开学!
2020年第二期<python接口自动化+python测试开发>课程,12月15号开学! 主讲老师:上海-悠悠 上课方式:QQ群视频在线教学,方便交流 本期上课时间:12月15号-3月29 ...