Use the if tag in the mybatis xml file to judge whether the strings are equal

Use the if tag in the mybatis xml file to judge whether the strings are equal

1. Method 1:
<if test="delFlag == '2'.toString()">
	a.del_flag = #{delFlag}
</if>



2. Method 2:

<if test=' delFlag == "2" '>
	a.del_flag = #{delFlag}
</if>


The above two can be implemented in the myBatis xml file to realize the judgment of the string.
3. Can not be used

<if test=" delFlag == '2' ">
	a.del_flag = #{delFlag}
</if>



Using "delFlag =='2' " in the above example, Mybatis will parse "2" as a character (java strongly typed language, '2' char type) instead of a string, which cannot be judged. To check if strings are equal in Mybatis, use method one or method two.


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325780972&siteId=291194637