悟道子的gravatar头像
悟道子 2020-06-02 14:33:50
mysql Select注解大于号,小于号趟过的坑

问题描述:业务中有一段sql语句咋瞅瞅都没发现啥问题

..........................

"<if test=\"startDate!=null and startDate!=''\">"+
"    and taskCreateDate>#{startDate}" +
"</if>" +
"<if test=\"endDate!=null and endDate!=''\">"+
"    and taskCreateDate<#{endDate}" +
"</if>" +
"</script>")

但是报错Caused by: org.xml.sax.SAXParseException: 元素内容必须由格式正确的字符数据或标记组成。

后来查相关资料发现

在@Select注解中采用script标签包围拼接SQL语句时不能在标签里有>大于或<小于符号出现,

否则会报Caused by: org.xml.sax.SAXParseException: 元素内容必须由格式正确的字符数据或标记组成。需要对这样的标签符号进行转义即可。

 

大于号:&gt;

小于号:&lt;

mysql Select注解大于号,小于号趟过的坑问题解决

 


打赏
最近浏览
80730176  LV7 2024年6月18日
liangge2115  LV27 2022年6月30日
112233123  LV1 2022年1月26日
追漫小白  LV1 2021年7月21日
giao哥 2020年11月3日
暂无贡献等级
悟道子  LV16 2020年6月2日
最代码官方  LV168 2020年6月2日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友