Escape of mybatis greater than or less

Source: Internet
Author: User

When writing code today, because the business needs to be used in mybatis, it is bigger than the number, less than the number, so it is directly used in SQL.
SELECT * FROM test WHERE 1 = 1 AND start_date <= CURRENT_DATE AND end_date> = CURRENT_DATE


However, an error is reported during execution:


Error creating document instance. Cause: org. xml. sax. SAXParseException; lineNumber: 74; columnNumber: 17; the content of the element must consist of correctly formatted character data or tags.
Remove AND start_date> = CURRENT_DATE AND end_date <= CURRENT_DATE, so there is no problem. Therefore, it is determined that the problem is caused by a number greater than or less than the number.
So I thought of the special symbols, So I replaced the> and <with escape characters, and then there was no problem.
SELECT * FROM test WHERE 1 = 1 AND start_date & lt; = CURRENT_DATE AND end_date & gt; = CURRENT_DATE

Appendix: XML escape characters
& Lt; <Yu no.


& Gt;> greater


& Amp; & and

& Apos; 'single quotes


& Quot; "Double quotation marks

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.