码迷,mamicode.com
首页 > 编程语言 > 详细

关于 There is no getter for property named 'id' in 'class java.lang.Integer'

时间:2020-04-01 19:24:41      阅读:138      评论:0      收藏:0      [点我收藏+]

标签:方法   注解   解决方法   where   使用   lang   lan   简单的   sql   

在写SSM框架的时候,请求报出 There is no getter for property named ‘id‘ in ‘class java.lang.Integer‘这个问题

但是实际上实体类中写了相关的方法,最后找到问题出现在Mapper接口中,

 List<User> getAllUser( Integer id);

将代码改为:

List<User> getAllUser(@Param("id") Integer id);

问题解决

 

 

 

方法2

当mapper的方法参数是基础类型且只有一个时,在mapper.xml文件中使用${}取值时,会报There is no getter for property named ‘id‘ in ‘class java.lang.Integer‘异常。

解决方法

1、@Param注解


 
public AreaDict selectById(@Param("id") Integer id);

 
select * from area_dict where area_dict_id = ${id}

2、将${}换成#{}取值,#{}能防止sql注入,${}只是简单的字符串替换,#{}先进行预处理

select * from area_dict where area_dict_id = #{id}
3、通过${value}或${_parameter}取值


 
select * from area_dict where area_dict_id = ${_parameter}

select * from area_dict where area_dict_id = ${value}

 

关于 There is no getter for property named 'id' in 'class java.lang.Integer'

标签:方法   注解   解决方法   where   使用   lang   lan   简单的   sql   

原文地址:https://www.cnblogs.com/roak/p/12614475.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!