zoukankan      html  css  js  c++  java
  • Mybatis特殊字符处理,Mybatis中xml文件特殊字符的处理

    Mybatis特殊字符处理,Mybatis中xml文件特殊字符的处理

    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

    蕃薯耀 2016年8月24日 10:18:51 星期三

    http://fanshuyao.iteye.com/

    一、问题描述:

    查询时,需要获取时间区间内的数据,如下:

    <if test="startTime != null" >
        and l.CREATE_TIME >= #{startTime}
    </if>
    <if test="endTime != null" >
         and l.CREATE_TIME < #{endTime} 
    </if>

    但是,Mybatis中xml 文件中,查询是不能使用小于号(<)的,因为这属于开始标签,是特殊字符

    二、解决方案

    在查询中,使用CDATA包括起来,就能避免特殊字符了。这方法适用所有的特殊字符。

    <![CDATA[ 
    	
    ]]>

    示例如下:

    <if test="startTime != null" >
        <![CDATA[ 
            and l.CREATE_TIME >= #{startTime}
        ]]>
    </if>
    <if test="endTime != null" >
        <![CDATA[ 
    	and l.CREATE_TIME < #{endTime} 
        ]]>
    </if>

    MyBatis返回主键,MyBatis Insert操作返回主键:

    http://fanshuyao.iteye.com/blog/2245853

    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

    蕃薯耀 2016年8月24日 10:18:51 星期三

    http://fanshuyao.iteye.com/

  • 相关阅读:
    scrapy 链接数据库创表语句
    工作问题总结
    插入排序
    centos6.5 安装python2.7.5
    冒泡排序
    [Python笔记]第十篇:模块续
    [Python笔记]第九篇:re正则表达式
    [Python笔记]第八篇:模块
    [Python笔记]第六篇:文件处理
    [Python笔记]第五篇:递归
  • 原文地址:https://www.cnblogs.com/fanshuyao/p/6227101.html
Copyright © 2011-2022 走看看