Detailed explanation of the implementation of Call, Apply, and Bind in JS (source code implementation)

2022-12-24   ES  

mybatis ﹤! [Cdata []]> Use



  WARNING - @mbggenerated
  This element is automatically generated by MyBatis Generator, do not modify.
  This element was generated on Thu Oct 10 09:46:29 CST 2013.
<if test="page != null">
  <![CDATA[ limit #{page.begin}, #{page.length} ) as temp_page_table) ]]>
  <if test="orderByClause != null">
    order by ${orderByClause}

The above code is the automatic code generated by the Generator of MyBatis, why add ﹤! [CDATA []]>? It feels completely unnecessary. The SQL statement inside does not destroy the XML document structure, or causes SQL errors? why?


Added instructions, I know its usage, I just don’t understand the paging of SQL
limit #{page.begin}, #{page.length} ) as temp_page_table) 
This statement, why add <! [Cdata []]>?

Solution 1:

cdata has nothing to do with mybatis.

The term CDATA refers to the text data (Unparsed Character Data) that should not be parsed by the XML parser. All the contents of the CDATA part are ignored by parsers.
As for your XML, even if there is no error, it has added CDATA, the landlord also said that it is the code that automatically generated through the generator. Since the automatic generation tool is naturally not as smart, it is only used in the most common way. This is nothing.

Solution 2:

Theoretically, this Limit does not need to add this. The Limit paging I use is never needed, but you still test it. After removing it, you will report an error. Prevent “<” such symbols in Mybatis Not recognize

Solution 3:

You have no SQL, it should be a unified CDATA to prevent your SQL from appearing in XML illegal characters such as “<” and “&”

Solution 4:

In XML elements, “<” and “&” are illegal.
“<” will cause errors because the parser will interpret the character as the beginning of the new element.
“&” will also cause errors, because parsers will interpret the character as the beginning of the character entity.
Some texts, such as JavaScript code, contain a large number of “<” or “&” characters. To avoid errors, the script code can be defined as CDATA.
CDATA section will be ignored by parsers.
Suppose there is such a SQL

SELECT * FROM users WHERE registerAt > 100

If you do not use CDATA packaging, XML parser goes back to analyze, and it will encounter “>” to cause the document structure errors

The above introduces the answer to the use of “MYBATIS! [CDATA []]> Use, I hope it will be helpful to netizens in need.

This article Links:


Related Posts

# 05-4 Class and 5 Class 5 LSA

HOMEBREW Uninstall: FaiLED to Locate Homebrew! Wrong Flyinginthe

.NET platform use Redis (5) [Stackexchange.redis and Protobuf-Net]

java API Simple Operation Hadoop

Detailed explanation of the implementation of Call, Apply, and Bind in JS (source code implementation)

Random Posts

Simply achieve the effect of horse rampant lights with code

(1) The role of JavaScript

qt Multi -thread programming object thread and function execution thread

Bugku CTF Web (Question 10-15)

Install VS2010 Chinese flagship version of Deepwater