Database

Mybatis) 조건문 if-else -> choose-when-otherwise

Greensky0026 2022. 8. 21. 15:08
반응형

mybatis에서 if-test만 사용하는게 아닌. if-else를 사용해야 할때 choose-when을 사용하면 됩니다.

 

<choose>

    <when test="condition1">
    	//codition1 is true, then running this block
    </when>
    
    <when test="condition2">
    	//condition1 is false and condition2 is true, then running this block
    </when>
    
    <otherwise>
    	//all contition is false, then running this block
    </otherwise?
    
 </choose>
반응형