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;      "

注意:要加上分号!

原文地址:https://www.cnblogs.com/wjunxia/p/5956159.html