Mybatis实现if else效果

<choose>  
     <when test="studentName !=null ">  
                ST.STUDENT_NAME LIKE CONCAT(CONCAT('%', #{studentName, jdbcType=VARCHAR}),'%')  
     </when >  
     <when test="studentSex != null and studentSex != '' ">  
           AND ST.STUDENT_SEX = #{studentSex, jdbcType=INTEGER}  
     </when >  
     <otherwise>  
     </otherwise>  
</choose>  测试

只要有一个when测试为true就会执行并跳出,若是都没命中则走otherwisetest

相关文章
相关标签/搜索