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

时间:2020-07-10 11:48:18   收藏:0   阅读:80

使用mybatis传入参数, 当参数类型是String ,Integer 等这些时。如果用他的<if test="year != null and year != ‘‘">标签判断该参数是否为空,通常会爆There is no getter for property named ‘year’ in ‘class java.lang.Integer异常。

也就是说如果我们不使用if标签进行判断的时候,只传单个这样的参数,是不会报这个错误的,已经亲测过。

技术图片

 

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

List<EneElectricity> getProAndLiveByMonth(Integer year);

注意只需要在mapper层中修改,其它层无需改动,将代码改为:

List<EneElectricity> getProAndLiveByMonth(@Param(value="year") Integer year);

问题解决。

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!