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>

  

posted @ 2020-04-26 10:04  深海可乐啤酒  阅读(473)  评论(0编辑  收藏  举报