Home > Database > Mysql Tutorial > body text

mybatis大于小于的转义

WBOY
Release: 2016-06-07 15:56:57
Original
1243 people have browsed it

今天在写代码时,因为业务,需要在mybatis中,使用到大于号,小于号,所以就在SQL中直接使用了。 SELECT * FROM test WHERE 1 = 1 AND start_date = CURRENT_DATE AND end_date = CURRENT_DATE 可是,在执行时,总报错误: Error creating document instance.

今天在写代码时,因为业务,需要在mybatis中,使用到大于号,小于号,所以就在SQL中直接使用了。
SELECT * FROM test WHERE 1 = 1 AND start_date = CURRENT_DATE

可是,在执行时,总报错误:

Error creating document instance. Cause: org.xml.sax.SAXParseException; lineNumber: 74; columnNumber: 17; 元素内容必须由格式正确的字符数据或标记组成。
把AND start_date >= CURRENT_DATE AND end_date 于是就想到了特殊符号,于是用了转义字符把>和 SELECT * FROM test WHERE 1 = 1 AND start_date <= CURRENT_DATE AND end_date >= CURRENT_DATE 

附:XML转义字符
< < 小于号

> > 大于号

& & 和

' ' 单引号

" " 双引号

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!