MyBatis Error – The content of elements must consist of well-formed character data or markup.
MyBatis 의 Mapper XML 파일에서 다음과 같은 오류가 발생 했다.
“The content of elements must consist of well-formed character data or markup.”
이는 SQL 연산자인 <, =, > 와 같은 엔터티가 MyBatis 문법과 혼동되서 나오는 문제다. 이럴때는 CDATA 를 적용해주면 된다.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
<select id="getCheckInDay" resultType="CheckInDayVO"> <![CDATA[ SELECT dayofweek, DATE(start_date) AS day, start_date, end_date, TIMEDIFF(end_date, start_date) AS worktime, CASE WHEN end_date is null OR TIMESTAMPDIFF(MINUTE,start_date,end_date) < 160 THEN TIMESTAMPDIFF(MINUTE,start_date,now()) ELSE TIMESTAMPDIFF(MINUTE,start_date,end_date) END workminute, CASE WHEN end_date is null OR TIMESTAMPDIFF(MINUTE,start_date,end_date) < 160 THEN (TIMESTAMPDIFF(MINUTE,start_date,now())/480)*100 ELSE (TIMESTAMPDIFF(MINUTE,start_date,end_date)/480)*100 END workpercentage FROM checkin WHERE username = #{username} AND DATE(start_date) = #{today} ]]> </select> |
이렇게하면 에러를 없앨 수 있다.