mybatis中寫sql語句時需要轉義的字符


mybatis配置文件,sql語句中含有轉義字符:

錯誤語句:

  select * from table_base where flag_topic  & #{topic_num}

錯誤信息:

  Caused by: org.xml.sax.SAXParseException; lineNumber: 8; columnNumber: 54; The entity name must immediately follow the '&' in the entity reference.

正確語句:

  select * from table_base where flag_topic   & #{topic_num}

將語句中的位運算(與)”&“符使用“&”替換

mybatis配置文件寫SQL語句的某些字符需要轉義:

  &lt;          < 
    &gt;          >  
    &lt;&gt;   <>
    &amp;      & 
    &apos;      '
    &quot;      "

注意:要加上分號!


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM