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

Posted caoxs

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Parameter 'xxx' not found. Available parameters are [collection, list]相关的知识,希望对你有一定的参考价值。

mybatis报错问题:

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]

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

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

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

 

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

   会报org.apache.ibatis.binding.BindingException: Parameter ‘xx‘ not found

以上是关于Parameter 'xxx' not found. Available parameters are [collection, list]的主要内容,如果未能解决你的问题,请参考以下文章

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

org.apache.ibatis.binding.BindingException: Parameter 'xxx' not found. Available parameters

Mybatis错误:Parameter 'XXX' not found. Available parameters are [1, 0, param1, param2]

Closure use of non-escaping parameter 'xxx' may allow it to escape

java 传入多个参数时报"Parameter 'XXX' not found. Available parameters are [arg1, arg0, param1,.

Required Integer[] parameter ‘xxx‘ is not present”报错的解决方案