使用了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里即可