MyBatis SQL XML processing less than and greater than sign

Source: Internet
Author: User

When we need to process SQL statements in XML format, we often use symbols such as <, <=,>,>= and so on, but it is easy to cause errors in XML format, which causes the background to convert XML strings to XML document times, which can lead to program errors.

Such problems often need us to deal with in Ibatis or in a custom XML-processing SQL program. In fact, it is very simple, we just need to replace the following to avoid the above error:

Original symbol < <= > >= & "
Replace symbol &lt; &lt;= &gt; &gt;= &amp; &apos; &quot;

Bad XML format:

[HTML]View Plaincopy
  1. <? XML version= "1.0" encoding="GBK"?>
  2. <queryform token="32sdfj-349sfdnfs32-fsdf348imfg323-df34" tablename="Hsy_t_customer" pagesize= "pageno=" 1 " ordercolumn= " "Ordertype=" ">
  3. <sqlcondition> and start_date >= to_date (' 2013-01-01 ', ' yyyy-mm-dd ') and start_date <= To_date (' 2013-01-30 ', ' yyyy-mm-dd ') </sqlcondition>
  4. </queryform>

Error in Altova XMLSpy tool, XML does not conform to format requirements.

The correct XML format:

[HTML]View Plaincopy
  1. <? XML version= "1.0" encoding="GBK"?>
  2. <queryform token="32sdfj-349sfdnfs32-fsdf348imfg323-df34" tablename="Hsy_t_customer" pagesize= "pageno=" 1 " ordercolumn= " "Ordertype=" ">
  3. <sqlcondition> and start_date &gt;= to_date (' 2013-01-01 ', ' yyyy-mm-dd ') and start_date &lt;= To_date (' 2013-01-30 ', ' yyyy-mm-dd ') </sqlcondition>
  4. </queryform>

MyBatis SQL XML processing less than and greater than sign

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.