mybatis报错:Error evaluating expression

mybatis的mapper文件中报了这么一个错

org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.builder.BuilderException: Error evaluating expression 'costsProgrammeVO.startTime != null AND costsProgrammeVO.endTime != null'. Cause: org.apache.ibatis.ognl.ExpressionSyntaxException: Malformed OGNL expression: costsProgrammeVO.startTime != null AND costsProgrammeVO.endTime != null [org.apache.ibatis.ognl.ParseException: Encountered " <IDENT> "AND "" at line 1, column 36.
Was expecting one of:
    <EOF> 
    "," ...
    "=" ...
    "?" ...
    "||" ...
    "or" ...
    "&&" ...
    "and" ...
    "|" ...
    "bor" ...
    "^" ...
    "xor" ...
    "&" ...
    "band" ...
    "==" ...
    "eq" ...
    "!=" ...
    "neq" ...
    "<" ...
    "lt" ...
    ">" ...
    "gt" ...
    "<=" ...
    "lte" ...
    ">=" ...
    "gte" ...
    "in" ...
    "not" ...
    "<<" ...
    "shl" ...
    ">>" ...
    "shr" ...
    ">>>" ...
    "ushr" ...
    "+" ...
    "-" ...
    "*" ...
    "/" ...
    "%" ...
    "instanceof" ...
    "." ...
    "(" ...
    "[" ...
    <DYNAMIC_SUBSCRIPT> ...
    ]
	at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:96)
	at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:441)
	at com.sun.proxy.$Proxy165.selectList(Unknown Source)
	at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:224)
	at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.executeForIPage(MybatisMapperMethod.java:121)
	at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.execute(MybatisMapperMethod.java:85)
	at com.baomidou.mybatisplus.core.override.MybatisMapperProxy$PlainMethodInvoker.invoke(MybatisMapperProxy.java:148)

代码:

           <if test="costsProgrammeVO.startTime != null AND costsProgrammeVO.endTime != null">
                and NOT ( cp.end_time <![CDATA[<]]> #{costsProgrammeVO.startTime} OR cp.start_time <![CDATA[>]]> #{costsProgrammeVO.endTime} )
            </if>

解决:if标签的test里面的表达式的and不能写成大写AND

posted on 2023-12-27 16:53  何苦->  阅读(1886)  评论(0编辑  收藏  举报

导航