當(dāng)使用Map做為參數(shù)和pojo作參數(shù)時(shí),兩者配置文件寫(xiě)法相同
<select id="SelectifwhereTestMap" parameterType="map" resultType="user">
select * from user
<where>
<if test="username!=null and username!=''">
and username like '%${username}%'
</if>
<if test="sex!=null and sex!=''">
and sex=#{sex}
</if>
<if test="address!=null and address!=''">
and address like '%${address}%'
</if>
</where><!--where可以去除第一個(gè)空格或者OR-->
</select>
```
<select id="SelectifwhereTestUser" parameterType="user" resultType="user">
select * from user
<where><!--where可以去除第一個(gè)空格或者OR-->
<if test="username!=null and username!=''">
and username like '%${username}%'
</if>
<if test="sex!=null and sex!=''">
and sex=#{sex}
</if>
<if test="address!=null and address!=''">
and address like '%${address}%'
</if>
</where>
</select>