版本:mybatis-3.5.4.jar
当使用foreach标签时出现:

编写的xml配置如下:
<select id="selectPeriodByCompanyNames" resultMap="result">
select id,
company_name,
`type`,
publish_time,
create_time,
title,
web_site,
source from company_news_sum
<where>
publish_time <![CDATA[>=]]> #{startTime}
and company_name in
<foreach collection="list" item="company_name" index="index" open="(" close=")" separator=",">
#{company_name}
</foreach>
</where>
</select>
- 在只有一个list参数或者array参数的时候,这样配置是好的,但是如果多个参数再这样配置就出错了
解决办法:collection配置修改为参数名称
<select id="selectPeriodByCompanyNames" resultMap="result">
select id,
company_name,
`type`,
publish_time,
create_time,
title,
web_site,
source from company_news_sum
<where>
publish_time <![CDATA[>=]]> #{startTime}
and company_name in
<foreach collection="companyNames" item="company_name" index="index" open="(" close=")" separator=",">
#{company_name}
</foreach>
</where>
</select>
网友评论