mybatis ![CDATA[ ]] 使用,小于大于号转义
使用Mybatis的xml文件中写sql语句时写入了一些特殊字符 如 < > & 等,但解析xml文件的时候会被转义
所以可以使用CDATA来避免这个问题
可以使用<![CDATA[ sql ]]>.
<select id="getKqzlAll" resultMap="BaseResultMap">
select
*
from KQZL
<where>
<if test="DWBH !=null and DWBH !=''">
DWBH=#{DWBH}
</if>
<if test="startTime !=null and startTime !=''">
and TO_CHAR(JLSJ,'YYYY-MM-DD HH24:MI:SS')<![CDATA[ >= ]]> #{startTime}
</if>
<if test="endTime !=null and endTime !=''">
and TO_CHAR(JLSJ,'YYYY-MM-DD HH24:MI:SS')<![CDATA[ <= ]]> #{endTime}
</if>
</where>
order by JLSJ desc
</select>

浙公网安备 33010602011771号