想在SSB(Spring+Spring MVC+MyBatis)中的Mapper.xml中配置查询语句,因为要用到比较大小,结果直接在里面写>=,编译就会出错,后来查询资料,才知道xml文件不直接支持>,<,',",& 它们需要转义字符才能被读取。
1、在xml的sql语句中,不能直接用大于号、小于号要用转义字符
如果用小于号会报错误如下:
org.apache.ibatis.builder.BuilderException: Error creating document instance. Cause: org.xml.sax.SAXParseException: The content of elements must consist of well-formed character data or markup.
转义字符
< | < | 小于号 |
> | > | 大于号 |
& | & | 和 |
' | ’ | 单引号 |
" | " | 双引号 |