웹개발 관련

[Mybatis] if 문자열 비교 NumberFormatException

반응형

 

 

Mybatis 에서 if문 사용시 문자열 비교할 때, 문자열이 하나 일 경우 숫자로 인식하여 에러 발생

 

 

<if test="type != null and type == 'A'">

       AND srch_type = #{type}

</if>

NumberFormatException  에러 발생

 

 

 

toString() 또는 equals 사용하면 해결!

 

<if test="type != null and type eq 'A'.toString()">

       AND srch_type = #{type}

</if>

 

 

<if test="type != null and type.equals('A')">

       AND srch_type = #{type}

</if>

반응형

'웹개발 관련' 카테고리의 다른 글

aws rds mysql 설치, 외부 접속, 캐릭터셋변경  (0) 2017.12.18
[ORACLE] pk 두개 생성하기  (0) 2017.07.19
[html]readonly, disabled 차이  (0) 2017.07.17
STS 메모리 설정  (0) 2017.07.12
[API] google URL shortner API  (0) 2017.06.30