【JAVA】 文件类型:mapper.xml 框架:MyBatis
控制台报错:
There is no getter for property named '__frch_item_0' in 'class [类名]'
错误写法:
<foreach collection="rightIds" index="index" item="item" open="("
separator="," close=")">
#{item}
</foreach>
正确写法:
<foreach collection="rightIds" index="index" item="item" open="("
separator="," close=")">
${item}
</foreach>
或者
<foreach collection="rightIds" index="index" item="item" open="("
separator="," close=")">
#{rightIds[${index}]}
</foreach>
本文介绍了在使用MyBatis框架进行数据库操作时,如何正确使用foreach标签来遍历集合。针对具体错误提供了两种解决方案,并解释了为何使用${}
8966

被折叠的 条评论
为什么被折叠?



