【问题标题】:spring expression not evaluating simple relational operatorspring 表达式不评估简单的关系运算符
【发布时间】:2017-05-17 14:24:15
【问题描述】:

为什么下面的代码在明显不是 TRUE 的情况下返回 TRUE?

        ExpressionParser parser = new SpelExpressionParser();
        Integer   s = new Integer(132);

        EvaluationContext context = new StandardEvaluationContext();
        context.setVariable("rpaCount", s);
        Expression exp = parser.parseExpression("#rpaCount>1000"); 
        Boolean truth = (Boolean)exp.getValue();


        System.out.println(truth); // returning TRUE ....HOW is 132 > 1000?

【问题讨论】:

    标签: spring-el


    【解决方案1】:

    似乎上下文为空,这就是表达式未正确评估的原因。我完全不了解 EvaluationContext 的用法,因此造成了混乱。澄清EvaluationContext的用法后结束问题。

    【讨论】:

      猜你喜欢
      • 2011-07-24
      • 2019-01-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-01-31
      • 1970-01-01
      • 1970-01-01
      • 2019-09-26
      相关资源
      最近更新 更多