Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SpEL parsing a valid expression, there is still more data in expression

I am using Spring Expression Language (SpEL) and created a sample program. The code snippet is

ExpressionParser parser=new SpelExpressionParser();
Expression expression=parser.parseExpression("Hello SPEL");

But got below error.

Exception in thread "main" org.springframework.expression.spel.SpelParseException: EL1041E:(pos 6): After parsing a valid expression, there is still more data in the expression: 'SPEL'
    at org.springframework.expression.spel.standard.InternalSpelExpressionParser.doParseExpression(InternalSpelExpressionParser.java:116)
    at org.springframework.expression.spel.standard.SpelExpressionParser.doParseExpression(SpelExpressionParser.java:56)
    at org.springframework.expression.spel.standard.SpelExpressionParser.doParseExpression(SpelExpressionParser.java:1)
    at org.springframework.expression.common.TemplateAwareExpressionParser.parseExpression(TemplateAwareExpressionParser.java:66)
    at org.springframework.expression.common.TemplateAwareExpressionParser.parseExpression(TemplateAwareExpressionParser.java:56)
like image 494
Udhay Avatar asked Apr 09 '15 09:04

Udhay


1 Answers

Try

Expression expression=parser.parseExpression("'Hello SPEL'");

instead.

The parameter is a String, but the parser needs to know that this is a string, because you can parse other things as well.

For more information, have a look here.

like image 140
Zaheylu Avatar answered Sep 22 '22 09:09

Zaheylu