Recent projects toss waited a long time to find the information to know such a thing. . .
Because the statement has a less-than sign, "<", in XML, will be treated as a page element to parse, mysql not treated as part of the SQL statement to read as follows:
1, in the xml sql statement can not be greater than the number directly, use number is smaller than the escape character
If the number is less than the error will be reported as follows:
org.apache.ibatis.builder.BuilderException: Error creating document instance. Cause: org.xml.sax.SAXParseException: The content of elements must consist of well-formed character data or markup.
Solution:
1, the escape character
< |
< |
Less than sign |
> |
> |
Greater than sign |
& |
& |
with |
' |
’ |
apostrophe |
" |
" |
Double quotes |
For example: state <= 3 then change to the state & lt; = 3
2, using <! [CDATA []]> tag
NOTE: <! [CDATA []]> sql statement tag in <where> <if> tag and the like are not resolved
<![CDATA[
state <= 3
]]>
In this way, the SQL statement will be the same XML page elements shield element is the XML does not parse it as XML elements to generate the correct SQL statement.