myhabits where in foreach

时间:2023-03-09 16:24:45
myhabits where in foreach

myhabits传入参数:类,其中类中包含字符串数组String[]

当查询where in String[]时

<select id="selectData" parameterType="DataDay"<!-- 类名 -->
resultMap="DataResult">
select * from
data_day
<where>
<if test="selectStringName != null and selectStringName!= '' and selectStringName.length!=0 ">
and selectName in
<foreach collection="selectStringName" <!-- 注意此处要写这个字符串数组的名称 --> item="selectStringName"
                    open="(" separator="," close=")">
#{selectStringName}
</foreach>
</if>
</where>
</select>

如果写成 collecton=“array”,会报错There is no getter for property named 'array' in 'class ...