[spring] ibatis, mybatis 동적태그
ibatis와 mybatis의 동적태그 비교 예제가 잘 되어 있는 사이트가 있어서 정리해둔다.
더 많은 예제는 출처사이트에서 확인할 수 있다.
ibatis 비교문 지원 태그
isNull : "널일경우"
isNotNull : "널이아닐경우"
isEmpty : "공백일경우"
isNotEmpty : "공백이아닐경우"
isGreaterTan : ">"
isGreaterEqual : ">="
isLessThan : "<"
isLessEqual : "<="
isEqual : "=="
isNotEqual : "!="
mybatis 비교문 지원 태그
if : 단일조건문
choose when otherwise : 다중조건문
예제
<!--ibatis -->
<isnull property="stringProperty">
조건문
</isnull>
<!--mybatis-->
<if test="stringProperty == null">
조건문
</if>
<!--ibatis-->
<isnotnull property="stringProperty">
<isnotempty property="stringProperty">
조건문
</isnotempty>
</isnotnull>
<!--mybatis-->
<if test="stringProperty != null and stringProperty == """>
stringProperty 속성값이 "title"이 아닐경우
</if>
위처럼 ibatis의 경우에는 태그안에 태그를 여러번 넣어줘야해서 솔직히 번거롭습니다.
하지만 mybatis는 JSTL과 동일한 문법으로 사용이 가능하여 편하게 비교문을 다중조건을 주어서 사용할 수 있습니다.
다만 다른 점이 있다면 && 문을 and || 문을 or 로 작성 해주셔야 합니다.
출처 : http://hellogk.tistory.com/100