mybatis传递list参数错误写法
List<String> selectByListTest01(List<String> myListParam);
报错:
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.binding.BindingException: Parameter ‘myListParam’ not found. Available parameters are [collection, list]
改正后的代码:
List<String> selectByListTest01(@Param("myListParam")List<String> myListParam);
测试结果:查询成功
xml中SQL,返回值是List或String,resultType的值都是"String"
<select id="selectByListTest01" parameterType="String" resultType="String">
select DISTINCT category from my_test01 t
<if test="myListParam != null">
where t.large_category in
<foreach collection="myListParam" item="item" open="(" close=")" separator=",">
#{item,jdbcType=VARCHAR}
</foreach>
</if>
</select>