当使用Map做为参数和pojo作参数时,两者配置文件写法相同
代码语言:javascript复制 <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可以去除第一个空格或者OR-->
</select>
```
代码语言:javascript复制<select id="SelectifwhereTestUser" parameterType="user" resultType="user">
select * from user
<where><!--where可以去除第一个空格或者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>