Home  >  Forum  >  Spring
Post New Query

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



Asked on October 04, 2013
I am using Spring Expression language (SPEL) and created a sample program. The code snippet is 

ExpressionParser parser = new SpelExpressionParser();
Expression exp = parser.parseExpression("You are Here");

But got below error.


Exception in thread "main" org.springframework.expression.spel.SpelParseException: EL1041E:(pos 4): After parsing a valid expression, there is still more data in the expression: 'are'
at org.springframework.expression.spel.standard.InternalSpelExpressionParser.doParseExpression(InternalSpelExpressionParser.java:86)
at org.springframework.expression.spel.standard.SpelExpressionParser.doParseExpression(SpelExpressionParser.java:56)
at org.springframework.expression.spel.standard.SpelExpressionParser.doParseExpression(SpelExpressionParser.java:32)
at org.springframework.expression.common.TemplateAwareExpressionParser.parseExpression(TemplateAwareExpressionParser.java:66)
at org.springframework.expression.common.TemplateAwareExpressionParser.parseExpression(TemplateAwareExpressionParser.java:56)

Any suggestion?



Replied on October 04, 2013
In SpEL while parsing string(with more than one word) enclose it with single quote(') .
Do it like

Expression exp = parser.parseExpression("'You are Here'");


Write Answer




©2019 concretepage.com | Privacy Policy | Contact Us