org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'userIds' in

本文解决了一个关于MyBatis在使用String类型参数结合条件判断标签时出现的异常问题,并提供了正确的解决方案。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

使用了mybatis+springmvc+mysql进行web开发,Tomcat启动时报如下异常:

org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'userIds' in 'class java.lang.String'

这一般是mybatis的xml映射文件问题,下面是源代码:


<select id="countForToday" resultType="int" parameterType="String">
  select count(*) from knowledgearticle where ka_date = current_date
  <if test="classid!=null and classid != ''">
   and ka_classid = #{classid}
  </if>
</select>

修改:如果parameterType为字符串(String)类型,则不能有<if></if>标签,如果必须使用<if></if>标签,则参数类型须为:JAVABEAN或者MAP。

如果参数为String类型,可以把参数改成MAP,在传参数的时候,把STRING放在MAP里即可

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值