码迷,mamicode.com
首页 > 移动开发 > 详细

MyBatis mapper.xml中SQL处理小于号与大于号

时间:2019-11-12 00:34:33      阅读:506      评论:0      收藏:0      [点我收藏+]

标签:param   table   column   select   ted   pac   tis   style   res   

这种问题在xml处理sql的程序中经常需要我们来进行特殊处理。

     其实很简单,我们只需作如下替换即可避免上述的错误:

 

< <= > >= & "

&lt;

&lt;=

&gt;

&gt;=

&amp;

&apos;

&quot;

例如常见的时间比较:

<select id="select" parameterType="xxx" resultMap="xxx">
    select
        distinct
        <include refid="Base_Column_List" />
    from xxx
    <where>
        <if test="createDate != null">
            create_date <= #{createDate}
        </if>
    </where>
</select>

  正确写法

 

<select id="select" parameterType="xxx" resultMap="xxx">
    select
        distinct
        <include refid="Base_Column_List" />
    from xxx
    <where>
        <if test="createDate != null">
            create_date &lt;= #{createDate}
        </if>
    </where>
</select>

 

MyBatis mapper.xml中SQL处理小于号与大于号

标签:param   table   column   select   ted   pac   tis   style   res   

原文地址:https://www.cnblogs.com/qingmuchuanqi48/p/11839253.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!