mybatis sql語句配置 符號不兼容 大於號 小於號


在mybatis中對sql語句中涉及到大於號,小於號,如何操作:

方法一、

將其放入到<![CDATA[  ]]>標簽中

如:

 

[html] view plain  copy
 
  1. <![CDATA[ 
  2.        and mm.ttime > to_date(#{startDateTime},'yyyy-mm-dd hh24:mi:ss') 
  3.        and mm.ttime <= to_date(#{endDateTime},'yyyy-mm-dd hh24:mi:ss') 
  4. ]]>  

 

方法二、

 

如果是在動態語句中,則需要轉換

如:

 

[html] view plain  copy
 
  1. <if test="startDateTime!=null"> and mm.ttime &gt; to_date(#{startDateTime},'yyyy-mm-dd hh24:mi:ss')</if>  
  2. <if test="endDateTime!=null"> and mm.ttime &lt;= to_date(#{endDateTime},'yyyy-mm-dd hh24:mi:ss')</if>  

 

符號:

    &lt;          < 
    &gt;          >  
    &lt;&gt;   <>
    &amp;      & 
    &apos;      '
    &quot;      "


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM