当前位置: 代码迷 >> 综合 >> There is no getter for property named ‘endTime‘ in ‘xxx‘
  详细解决方案

There is no getter for property named ‘endTime‘ in ‘xxx‘

热度:12   发布时间:2024-02-07 17:10:27.0

There is no getter for property named ‘endTime’ in ‘xxx’

原本我的mybatis对应的mapper的xml文件中,代码写的是

<if test="bean.startTime!=null and bean.startTime!='' and bean.endTime!=null and endTime!=''">and i.create_time between #{bean.startTime} and #{bean.endTime}
</if>

就报错误:

There is no getter for property named 'endTime' in 'xxx'

此时我的endTime是没有值的,然后我将上述代码改成了

<if test="bean.startTime!=null and bean.startTime!='' and (bean.endTime!=null and endTime!='')">and i.create_time between #{bean.startTime} and #{bean.endTime}
</if>

就ok!
从原因上来讲,举个例子,当判断字符串xx是否为空字符串时,
错误写法是:

if(xx==""){
}

这样就会报错,应该用下面写法去判断空字符串

if("".equals(xx)){
}

OK!分享一波用法!不会的给我私信或者回复留言!
觉得有帮助的可以关注一波!经常分享编程踩坑经验!

  相关解决方案