在MyBatis的各种标签中,<iftest>标签可以算的上是高频使用的一个标签了。

        在mybatis中不等于一般是

<if test="formNumber != null and formNumber != ''">

参数需要匹配相等的情况。

List<SystemProperty> iftest(@Param("param") String param,
@Param("integer") Integer integer);

        字符串类型:使用 '字符串'.toString()

        数字类型:直接使用== 

<select id="iftest" resultType="cn.tyzhou.jwf.property.model.dataobject.SystemProperty">

SELECT * FROM T_SYSTEM_PROPERTY
WHERE 3=3
-----------------------数字类型----------------------------------------
<if test=" integer!= null and integer ==1">
AND 1=1
</if>
<if test=" integer!= null and integer == 2">
AND 2=2
</if>
-----------------------字符串类型----------------------------------------
<if test=" param!= null and param == 'hot'.toString()">
ORDER BY SN DESC
</if>
<if test=" param!= null and param == 'cold'.toString()">
ORDER BY SN ASC
</if>
<if test=" param!= null and param == '1'.toString()">
ORDER BY ID DESC
</if>
<if test=" param!= null and param == '2'.toString()">
ORDER BY ID ASC
</if>