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

相關文章
相關標籤/搜索