Spring Snippet - Mybatis 문자열 비교

상황

  • 아래와 같이 작은 따옴표로 문자열 비교하게되면 NumberformatException 발생
<if test="appService ==1 and martTypeCode != 'N'">
    , #{svcStartDate}
    , #{svcEndDate}
</if>

해결

  • 비교하는 문자열을 큰따옴표로 변경하고, 태그 속성 값을 작은 따옴표로 변경함
<if test='appService ==1 and martTypeCode != "N"'>
    , #{svcStartDate}
    , #{svcEndDate}
</if>