ExpressionParser parser = new SpelExpressionParser();(2)
StandardEvaluationContext context = new StandardEvaluationContext();
// evals to "Hello World"(3)
String helloWorld = (String) parser.parseExpression("'Hello World'").getValue();(4)
double avogadrosNumber = (Double) parser.parseExpression("6.0221415E+23").getValue();(5)
int maxValue = (Integer) parser.parseExpression("0x7FFFFFFF").getValue();(6)
boolean trueValue = (Boolean) parser.parseExpression("true").getValue();(7)
Object nullValue = parser.parseExpression("null").getValue();(8)
int year = (Integer) parser.parseExpression("Birthdate.Year + 1900").getValue(context);(9)
boolean trueValue = parser.parseExpression("2 == 2").getValue(Boolean.class);(10)
boolean trueValue = parser.parseExpression("'black' < 'block'").getValue(Boolean.class);(11)
boolean falseValue = parser.parseExpression("'xyz' instanceof T(int)").getValue(Boolean.class);(12)
boolean trueValue = parser.parseExpression("'5.00' matches '^-?\\d+(\\.\\d{2})?$'").getValue(Boolean.class);
1714



被折叠的 条评论
为什么被折叠?



