티스토리 뷰

728x90

mybatis에서 비교 연산자 사용하는 중에 특수문자 에러 발생 

<select id="selectA" resultMap="MemberResultMap">
  select *
  from A
  where  year < 2020
</select>

error : The content of elements must consist of well-formed character data or markup.

해결방법 

 1. <![CDATA ]]> 사용 

<select id="selectA" resultMap="MemberResultMap">
  select *
  from A
  where  year  <![CDATA < ]]> 2020
</select>

 2. &lt; 사용 

<select id="selectA" resultMap="MemberResultMap">
  select *
  from A
  where  year &lt; 2020
</select>
&gt;
< &lt;
>= &gt;=
<= &lt;=

 

 

 

 

 

참고 :

 

[Mybatis] 비교연산자 부등호 >,< 안될때

쿼리를 작성하다 보면 부등호 (>,<) 를 사용해야 할 때가 있다. 그러나 mybatis에서 사용하면 에러가 나는데 이때 해결방법을 알아 보자. 쿼리에 부등호 기호를 사용하면 The content of elements must consist

yamea-guide.tistory.com