在XML映射SQL的文件中,不少状况下会使用到大于号、小于号等特殊符号,这时候若是不进行控制是没法编译经过的,这时候须要用到<![CDATA[ ]]>符号进行说明,将此类符号不进行解析,其实,这个问题不止在MyBatis上通用,而是它通用于任何XML的文件中使用,好比Hibernate、Wabacus、Spring等等等等配置文件中,只要是XML文件就行,此类问题在之后的工做中,常用。html
案例代码spa
<select id="findAllKiaAnalysisByCondition" parameterType="map" resultType="KiaAnalysis"> select * from (select unitname, to_char(rdate,'yyyy-MM') rdate,keytype, scope from KIAANALYSIS <where> <if test='startDate!="%null%"'> and rdate >= to_date(#{startDate},'yyyy-mm')</if> <if test='endDate!="%null%"'> <strong><span style="color:#3333ff;"><![CDATA[</span><span style="color:#3366ff;"> </span></strong>and rdate <= to_date(#{endDate},'yyyy-mm') <span style="color:#3333ff;"><strong>]]></strong></span> </if> <if test='unitname!="%null%"'>and unitname=#{unitName}</if> </where> ) pivot (sum(scope) for keytype in(${themes})) </select>