mybatis:org.apache.ibatis.ognl.ParseException: Encountered " <IDENT> "OR "" at line 1, column 26错误解决

在mybatis项目中有一个sql做了对list集合做判空操作,sql如下:

<if test="personnelHasList == null OR personnelHasList.size == 0">

运行项目的时候发现时不时会出现以下报错情况:

Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.builder.BuilderException: Error evaluating expression ‘personnelHasList == null OR personnelHasList.size == 0’. Cause: org.apache.ibatis.ognl.ExpressionSyntaxException: Malformed OGNL expression: personnelHasList == null OR personnelHasList.size == 0 [org.apache.ibatis.ognl.ParseException: Encountered ” “OR “” at line 1, column 26.
Was expecting one of:

“,” …
“=” …
“?” …
“||” …
“or” …
“&&” …
“and” …
“|” …
“bor” …
“^” …
“xor” …
“&” …
“band” …
“==” …
“eq” …
“!=” …
“neq” …
“<” …
“lt” …
“>” …
“gt” …
“<=” …
“lte” …
“>=” …
“gte” …
“in” …
“not” …
“<<” …
“shl” …
“>>” …
“shr” …
“>>>” …
“ushr” …
“+” …
“-” …
“*” …
“/” …
“%” …
“instanceof” …
“.” …
“(” …
“[” …

]] with root cause
org.apache.ibatis.ognl.ParseException: Encountered ” “OR “” at line 1, column 26.
Was expecting one of:

“,” …
“=” …
“?” …
“||” …
“or” …
“&&” …
“and” …
“|” …
“bor” …
“^” …
“xor” …
“&” …
“band” …
“==” …
“eq” …
“!=” …
“neq” …
“<” …
“lt” …
“>” …
“gt” …
“<=” …
“lte” …
“>=” …
“gte” …
“in” …
“not” …
“<<” …
“shl” …
“>>” …
“shr” …
“>>>” …
“ushr” …
“+” …
“-” …
“*” …
“/” …
“%” …
“instanceof” …
“.” …
“(” …
“[” …

一开始在网上查询该报错信息,采纳了一个这样的说法:存在不合法的符号,  
导致xml解析不成功。于是从其他能运行通过的xml文件中复制了==号,发现  
还真的运行成功了,当时时间紧迫,手头还有其他任务,便没有仔细去验证多  
几次,如果多验证几次,就会发现实际问题还是存在(这一点我到现在也还没  
明白为何开始的时候可以运行成功),之后我试着将“OR”改成“or”和 改成  
“||”,发现就会没问题,初步判断是mybatis中不识别大写OR的原因。
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值