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语句的某些字符需要转义:
< <
> >
<> <>
& &
' '
" "
注意:要加上分号!
本文介绍了在MyBatis配置文件中编写SQL语句时需要进行转义的特殊字符及其正确的转义方式,帮助开发者避免因语法错误导致的问题。
5824

被折叠的 条评论
为什么被折叠?



