注意:1.由于在后台中使用模糊查询时不方便,我们可以将模糊查询写道mapper.xml中 concat("%",#{name},"%") 一定得使用concat
2.>、 >=、<、<=由于在某些场合会更一些标签符号产生冲突,可以是用gt(>) ge(>=) lt(<) le(<=)进行替换,后面不要忘了跟**;**
3.使用 <![CDATA[ ]]>可以不用替换符号也可以
<select id="queryList" parameterType="teacherQuery" resultType="teacher">
select * from t_tea
<where>
<if test="name!=null">
<!--拼接在测试中可以代替"%%" 必须使用concat-->
and name like concat("%",#{name},"%")
</if>
<!--
gt(>) ge(>=) lt(<) le(<=)
<![CDATA[ ]]>
-->
<if test="minAge!=null">
and age >#{minAge}
</if>
<!--将<当成标识符所以需要转义-->
<!--<if test="maxAge!=null">
and age < #{maxAge}
</if>-->
<if test="maxAge!=null">
<![CDATA[
and age < #{maxAge}
]]>
</if>
</where>
</select>