mybatis escape greater than less than

When writing code today, because of business, I need to use greater than and less than symbols in mybatis, so I use it directly in SQL.
SELECT * FROM test WHERE 1 = 1 AND start_date <= CURRENT_DATE AND end_date >= CURRENT_DATE

However, when executing, the total error is reported:

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

P.S. XML escape characters

                 &lt;           <      小于号                                           

                 &gt;          >    大于号

                 &amp;       &      和

                 &apos;     '   单引号

                 &quot;     "     双引号

Reprint address: https://blog.csdn.net/gisredevelopment/article/details/27870833

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325946776&siteId=291194637