3
SELECT *
FROM mytable
<foreach item="item" index="index" collection="myhashmap.entrySet()" open=" WHERE (" separator=" OR ("> table.attribute= #{item.key}
<foreach item="item2" index="index" collection="#{item.value}" separator=" ," open=" AND table.attribute IN (" close="))">
#{item2.value}
</foreach>
</foreach>
对散列表的迭代有效,但列表(它在item.value中)不起作用。MyBatis - 遍历整个列表,它是嵌套的foreach循环中的HashMap的值
Map<Integer, List<Integer>> myhashmap = new HashMap<Integer, List<Integer>>();
{item.value.iterator()}不起作用。
Exception:
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.builder.BuilderException: Error evaluating expression '#{item.value}'. Return value ({[5800]=null}) was not iterable.
其中5800是List
任何帮助表示赞赏的整数值!
你试过item.getValue()未经#{} – vvs
没有,没有工作。 – 98percentmonkey