Handle greater than sign less than sign in SQL in MyBatis

Source: Internet
Author: User
Tags cdata

Because the XML format, "<", ">" and other symbols can not be casually appear, so in SQL this kind of symbols to be special processing

The first method: replace special symbols with escape characters

  For example select * from Jy_handle WHERE createtime > "2017-07-27 00:00:00" can be converted to

SELECT * from Jy_handle WHERE createtime &gt; "2017-07-27 00:00:00"

Replace ">" with &gt;

The following are common XML escape characters

XML Common escape Character descriptor
> &lt;
< &gt;
& &amp;
&apos;
" &quot;

Second approach: Using <! [cdata[]]> For instructions, do not parse this symbol, examples are as follows:

  For example, select * from test WHERE createtime > "2017-07-27 00:00:00" can be converted to

    <! [cdata[SELECT * from Test WHERE createtime > "2017-07-27 00:00:00" ]]>  

Handle greater than sign less than sign in SQL in MyBatis

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.