问题一、执行mybatis某个查询的时候,抛出如下异常是怎么回事?
堆栈信息:org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.builder.BuilderException: Error evaluating expression 'fileType != null and (fileType=="IMAGE" OR fileType=="VIDEO" OR fileType=="PSD")'. Cause: org.apache.ibatis.ognl.ExpressionSyntaxException: Malformed OGNL expression: fileType != null and (fileType=="IMAGE" OR fileType=="VIDEO" OR fileType=="PSD") [org.apache.ibatis.ognl.ParseException: Encountered " <IDENT> "OR "" at line 1, column 41.
Was expecting one of:
"," ...
"=" ...
"?" ...
"||" ...
"or" ...
"&&" ...
"and" ...
"|" ...
"bor" ...
"^" ...
"xor" ...
"&" ...
"band" ...
"==" ...
"eq" ...
"!=" ...
"neq" ...
"<" ...
"lt" ...
">" ...
"gt" ...
"<=" ...
"lte" ...
">=" ...
"gte" ...
"in" ...
"not" ...
"<<" ...
"shl" ...
">>" ...
"shr" ...
">>>" ...
"ushr" ...
"+" ...
"-" ...
"*" ...
"/" ...
"%" ...
"instanceof" ...
"." ...
"(" ...
")" ...
"[" ...
<DYNAMIC_SUBSCRIPT> ...
]
原因:mybatis 不识别大写的OR AND 等关键词
fileType != null AND (fileType=="IMAGE" OR fileType=="VIDEO" OR fileType=="PSD")
把这里 大写的AND
和OR
改成小写and
和or
即可解决。
扩展:
eq
同==
,or
同||
所以,以上也可以改写成fileType != null and (fileType eq "IMAGE" || fileType eq "VIDEO" || fileType eq "PSD")
网友评论