MyBatis 的 xml 文件中 大于号和小于号的处理方式

nested exception is 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.

这是因为mybatis的mapper文件是xml格式的,所以不允许出现类似“>”这样的字符,解决方案如下:

方案一:

                     <                                 

                     <

                     小于号                                           

                     &gt;

                     >                                      

                     大于号

                     &amp;

                     &

                     和

                     &apos;

                     ’

                     单引号

                     &quot;

                     ”

                     双引号



方案二:

可以使用

<![CDATA[ when min(starttime)<='12:00' and max(endtime)<='12:00' ]]>  

参考资料:

1、 mybatis在xml中处理大于号,解决The content of elements must consist of well-formed character data or markup
https://blog.csdn.net/Lin_xiaofeng/article/details/79128291

2、mybatis异常:The content of elements must consist of well-formed character data or markup.
https://blog.csdn.net/wlsyn/article/details/8279422


版权声明:本文为HeatDeath原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。