mybatis 数组报错 There is no getter for property named '__frch_item_0'

来源:互联网 发布:爱福窝云设计软件 编辑:程序博客网 时间:2024/05/08 02:37

 因为sql中要用到 in,查了一下才知道 查询中有用到in的一定要 用foreach才行,否则的话虽然不会报错但是一定查不出数据。

所以我就在bean里面定义了一个Priavte List<String>  currUserStr;

...set..(自动生成的set get方法)

...get..

但是发现在

<select id="queryInfo" parameterType="queryCountEntity" resultType="HashMap">
select * from V_BZ_INFO 
where  user_id in
<if test="currUserStr!=null">
     <foreach item="item" index="index" collection="currUserStr" open="("  separator="," close=")">  
              #{item}
      </foreach>  
</if>
</select>

  一直报

org.apache.ibatis.reflection.ReflectionException: There is no getter for property named '__frch_item_0' in 'class com.ffcs.eda.pojo.sysman.QueryCountEntity'

最后终于发现是#{item}的问题

改成'${item}'问题解决

    这里写的不是很详细,顺便推荐一篇文章给你们看http://my.oschina.net/castusz/blog/67828

后来发现用in 的话 #改${}还是可以直接查询的,不用foreach


    

1 1
原创粉丝点击