<![CDATA[]]>

<![CDATA[]]>这个标记所包含的内容将表示为纯文本,比如<![CDATA[<]]>表示文本内容“<”

<if test="startDate!=null and startDate!=''">
    AND to_char(t1.gather_date, 'yyyy-mm-dd') <![CDATA[>=]]> #{startDate}
</if>
<if test="endDate!=null and endDate!=''">
    AND to_char(t1.gather_date, 'yyyy-mm-dd') <![CDATA[<=]]> #{endDate}
</if>

上面这种是将数据库的date格式转换成字符串格式,从而进行比较。

转义字符:

在XML中,需要转义的字符有:1、< &lt;,2、> &gt;,

<if test="null!=startDate and startDate !=''">
    and t3.upload_time &gt;= to_date('${startDate}','yyyy-mm-dd')
</if>
<if test="null!=endDate and endDate !=''">
    and t3.upload_time &lt;= (to_date('${endDate}','yyyy-mm-dd')+1)
</if>

这种是将传递过来的字符串类型的日期转成date类型的日期,然后跟数据库中的date格式的日期进行比较。

大于等于 <![CDATA[ >= ]]>

小于等于 <![CDATA[ <= ]]>

不等于 <![CDATA[ <> ]]>

 

posted on 2022-09-15 18:30  周文豪  阅读(4956)  评论(0编辑  收藏  举报