mybatis xml is sql statement error: Error creating document instance Cause:. org.xml.sax.SAXParseException: The

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

                     &lt;                                 

                     <

                     Less than sign                                           

                     &gt;

                     >                                      

                     Greater than sign

                     &amp;

                     &

                     with

                     &apos;

                     ’

                     apostrophe

                     &quot;

                     "

                     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.

Guess you like

Origin www.cnblogs.com/zhuyeshen/p/11981961.html