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