Parameter 'xxx' not found. Available parameters are [collection, list]

mybatis报错问题:sql

dao层: List<HqjTrade> queryHongbao(ArrayList<String> listType); 映射文件下sql: <select id="queryHongbao" resultType="HqjTrade" > select * from hqj_trade where tradetype in <foreach collection="listType" open="(" close=")" separator="," item="tradetype"> #{tradetype} </foreach>
  </select>

运行报错:Parameter 'listType' not found. Available parameters are [collection, list]apache

解决:1.通用方法,在dao层参数上加上@Param("listType"),因此养成加@Param是个好习惯数组

        2.将sql中Collection="listType"改成 Collection="list"或者"collection"mybatis

        3.对应方式处理二,若是参数是数组则这么改: Collection="array"spa

 

注意:也不是任何参数以前就加上@Param,实体类以前不须要加上注解@Paramcode

   会报org.apache.ibatis.binding.BindingException: Parameter 'xx' not foundblog

相关文章
相关标签/搜索