MyBatis Error evaluating expression;Malformed OGNL expression;Encountered xxx at line x,column x问题解决
问题描述:
Servletnested exception is org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.builder.BuilderException: Error evaluating expression ‘type!=${@com.constants.UserConstants@TYPE_READ}‘. Cause: org.apache.ibatis.ognl.ExpressionSyntaxException: Malformed OGNL expression: type!=${@com.constants.UserConstants@TYPE_READ} [org.apache.ibatis.ognl.ParseException: Encountered “ “$” “$ “” at line 1, column 11.
问题分析:
1、Mybatis标签里面的OGNL表达式使用Java常量时,语法不正确导致报错。
<if test="type!=${@com.constants.UserConstants@TYPE_READ}">
</if>
解决办法:
正确格式为@包名.类名@常量名。更多Java常量和静态方法的使用请查看以下博客。
MyBatis 使用Java常量和静态方法2种情况(SQL语句使用,OGNL表达式使用)
<if test="type!=${@com.constants.UserConstants@TYPE_READ}">
</if>
还没有评论,来说两句吧...