Mybatis篇.在xml文件中迭代数组与集合

it2022-05-05  135

数组

//判断数组是否为空且长度是否为0 <if test="id != null and id.length > 0"> <foreach collection="id" open="(" close=")" item="item" separator=","> ${item} </foreach> </if>

集合

//判断集合是否为空且长度是否为0 <if test="list != null and list.size() > 0"> <foreach collection="list" open="" close="" separator="," item="item"> ( #{item.serverName}, #{item.className}, #{item.methodName}, #{item.userId}, #{item.userName}, #{item.url}, #{item.ip}, #{item.beginTime}, #{item.relativeId} ) </foreach> </if>

最新回复(0)