zoukankan      html  css  js  c++  java
  • MyBatis中特殊符号的转义

    在MyBatis中遇到特殊符号时有两种转义方式:

    第一种

    描述 空格 小于 大于 小于等于 大于等于 单引号 双引号
    原符号 < > <= >= & ' "
    替换符号 &nbsp; &lt; &gt; &lt;= &gt;= &amp; &apos; &quot;

    例如:

    
    <select id = "selectUserByAge" resultType="com.test.hiioc.model.UserTable" >
        select
            id,userName,age
        from
            userTable
        <where>
            IS_DELETE = 1
            /*时间段查询*/
            <if test = "userTable.startDate!=null">
                and SIGNING_DATE &gt;= #{userTable.startDate}
            </if>
            <if test = "userTable.endDate != null">
                and SIGNING_DATE &lt;= #{userTable.endDate}
            </if>
        </where>
    </select>
    
    

    第二种

    使用 <![CDATA[>=]]> 进行转义

    例如:

    
    <select id = "selectUserByAge" resultType="com.test.hiioc.model.UserTable" >
        select
            id,userName,age
        from
            userTable
        <where>
            IS_DELETE = 1
            /*时间段查询*/
            <if test = "userTable.startDate != null">
                and SIGNING_DATE <![CDATA[>=]]> #{userTable.startDate}
            </if>
            <if test = "userTable.endDate!=null">
                and SIGNING_DATE <![CDATA[<=]]> #{userTable.endDate}
            </if>
        </where>
    </select>
    
    
  • 相关阅读:
    c++关于map的find和count的使用
    leetcode Two Sum
    leetcode Group Anagrams
    机器学习常见算法分类汇总
    KD树
    偏差与方差(未完)
    线性模型
    决策树
    Linux服务器配置---ftp用户黑名单
    Linux基础命令---mkdir
  • 原文地址:https://www.cnblogs.com/orangebooks/p/11806513.html
Copyright © 2011-2022 走看看