出现错误代码:
org.apache.ibatis.binding.BindingException: Parameter 'orderDetails' not found. Available parameters are [orderDetailList, collection, list]
错误原因:因为Mybatis识别不了你的参数列表,所以才报这个错。
void insertBatch(ArrayList<OrderDetail> orderDetailList);
<foreach collection="orderDetails" item="od" separator=",">
(#{od.name},#{od.orderId},#{od.dishId},#{od.setmealId},#{od.dishFlavor},# {od.number},#{od.amount},#{od.image})
</foreach>
修改后:
<foreach collection="orderDetailList" item="od" separator=",">
(#{od.name},#{od.orderId},#{od.dishId},#{od.setmealId},#{od.dishFlavor},#{od.number},#{od.amount},#{od.image})
</foreach>
参数为:orderDetailList,而我写成orderDetails,修改后问题成功解决。