Announcement Announcement Module
Collapse
No announcement yet.
TypeConversion in SpEL Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • TypeConversion in SpEL

    Hi,

    I have this test:

    Code:
    		SpelExpressionParser p = new SpelExpressionParser();
    		List<Object> data = new ArrayList<Object>();
    		data.add(1);
    		data.add("1");
    		Expression exp = p.parseExpression("#root[0] == #root[1]");
    		StandardEvaluationContext context = new StandardEvaluationContext(data);
    		context.setTypeConverter(new StandardTypeConverter());
    		assertTrue((Boolean)exp.getValue(context));
    I get this exception:

    Code:
    org.springframework.expression.spel.SpelEvaluationException: EL1013E:(pos 0): Cannot compare instances of class java.lang.Integer and class java.lang.String
    	at org.springframework.expression.spel.support.StandardTypeComparator.compare(StandardTypeComparator.java:69)
    	at org.springframework.expression.spel.ast.OpEQ.getValueInternal(OpEQ.java:51)
    	at org.springframework.expression.spel.ast.OpEQ.getValueInternal(OpEQ.java:1)
    	at org.springframework.expression.spel.ast.SpelNodeImpl.getValue(SpelNodeImpl.java:93)
    	at org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:88)
    What do I have to do, that this implicit conversion takes place? Just calling context.setTypeConverter(new StandardTypeConverter()) does not do the work...

    Thank you!

  • #2
    Uh, no one an idea?

    Comment

    Working...
    X