当前位置: 移动技术网 > IT编程>开发语言>Java > Parameter 'xxx' not found. Available parameters are [collection, list]

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

2018年06月26日  | 移动技术网IT编程  | 我要评论

tian,米莲物语,车标大全图片及名称

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

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网