首页 > 其他分享 >MyBatis的Mapper.xml文件中处理大于号小于号的方法

MyBatis的Mapper.xml文件中处理大于号小于号的方法

时间:2023-01-30 10:14:52浏览次数:36  
标签:xml 00 01 大于号 小于号 select

由于xml中">"和"<"都是有特殊意义的,所以sql语句中不能再使用">"和"<"符号,就需要进行处理.

比如:

select * from t_doc where create_time < '2023-01-30 11:00:00'

方式一: 使用转义字符替换

符号 符号中文名 转义后的符号
< 小于号 &lt;
> 大于号 &gt;
& &amp;
' 单引号 &apos;
" 双引号 &quot;

使用转义字符替换后为:

select * from t_doc where create_time &lt; '2023-01-30 11:00:00'

方式二: 使用<![CDATA[]]>标记,将其中的内容表示为纯文本

使用<![CDATA[]]>标记后为:

select * from t_doc where create_time <![CDATA[<]]> '2023-01-30 11:00:00'

标签:xml,00,01,大于号,小于号,select
From: https://www.cnblogs.com/antusheng/p/17074511.html

相关文章