Adjust the greeeting
method as follows. Notice that Integer.class
is passed to getValue()
.
public void greeting(String name)
{
ExpressionParser parser = new SpelExpressionParser();
Expression exp = parser.parseExpression(name);
String message = exp.getValue(Integer.class).toString();
System.out.println("Hello and welcome to Spring: " + message);
}
Then call with:
instance.greeting("5+5");