Announcement Announcement Module
Collapse
No announcement yet.
Spring Expression Language (spel) and variable name with dot (.) Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring Expression Language (spel) and variable name with dot (.)

    Hi,
    I didn't find a specific forum for spel so I'm posting here.
    I'm using spel to evaluate expression, but I've problem with this case:

    Case success (It returns true):
    Code:
    StandardEvaluationContext context = new StandardEvaluationContext();
    context.setVariable("ns.num5", 5.5f);
    context.setVariable("ns.num6", 5.5f);
    PARSER.parseExpression("#ns?.num5 == #ns?.num6").getValue(context, Boolean.class);
    I suppose it's ok, because variable names are differrent without namespace.


    Case failed (It returns false insteadof true):
    Code:
    StandardEvaluationContext context = new StandardEvaluationContext();
    context.setVariable("num5", 5.5f);
    context.setVariable("ns.num5", 5.5f);
    PARSER.parseExpression("#ns?.num5} <= #num5").getValue(context, Boolean.class);
    PARSER.parseExpression("#ns?.num5} == #num5").getValue(context, Boolean.class)
    ;

    I guess spel confuses variable names which are identicals without namespace (dot in name).
    Any suggestions?

    Thanks.
    Mickael
Working...
X