List和Map作为一个实体类的属性:
private List<Long> kkids;
public List<Long> getKkids() {
return kkids;
}
public void setKkids( List<Long> kkids) {
this.kkids = kkids;
}
private Map<String,String> multiGwsj;
public Map<String, String> getMultiGwsj() {
return multiGwsj;
}
public void setMultiGwsj(Map<String, String> multiGwsj) {
this.multiGwsj = multiGwsj;
}
mapper.xml
<if test="kkids != null">
<foreach collection="kkids" item="stationId" index="index" open="and (" close=")" separator=" or ">
kkid= #{stationId,jdbcType=VARCHAR}
</foreach>
</if>
<if test="multiGwsj != null">
<foreach collection="multiGwsj" item="time2" index="time1" open="and (" close=")" separator=" or ">
gwsj BETWEEN #{time1,jdbcType=TIMESTAMP} and #{time2,jdbcType=TIMESTAMP}
</foreach>
</if>
foreach处理array和list时,item是其中具体的一项,index是该项在列表或者数组中的位置;
处理map时,item是value,index是key