我正在尝试在表达式 String 中使用 BigDecimal Literal
我正在使用 JEXL 2.1.1
我正在使用 http://commons.apache.org/jexl/reference/syntax.html#Literals 中提到的文字后缀“h”
JexlEngine expressionFactory = new JexlEngine();
JexlContext context = new MapContext();
context.set ( "a", new BigDecimal( "0.0002" ));
Expression expression = expressionFactory.createExpression(" a > 42.0h " );
boolean result=(Boolean)expression.evaluate( context );
我遇到了异常
org.apache.commons.jexl2.JexlException$Parsing: h@1:24 parsing error near '... , missing ...'
at org.apache.commons.jexl2.parser.JexlParser.jjtreeCloseNodeScope(JexlParser.java:126)
at org.apache.commons.jexl2.parser.Parser.ExpressionStatement(Parser.java:274)
at org.apache.commons.jexl2.parser.Parser.Statement(Parser.java:140)
at org.apache.commons.jexl2.parser.Parser.JexlScript(Parser.java:72)
at org.apache.commons.jexl2.parser.Parser.parse(Parser.java:24)
at org.apache.commons.jexl2.JexlEngine.parse(JexlEngine.java:1248)
at org.apache.commons.jexl2.JexlEngine.createExpression(JexlEngine.java:435)
at org.apache.commons.jexl2.JexlEngine.createExpression(JexlEngine.java:419)
最佳答案
这看起来像是一个文档错误。
正确的大十进制后缀是“B”(而不是“H”)
正确的大整数后缀是“H”(而不是“B”)
通过查看 ASTNumberLiteral.java 可以清楚地验证这一点
关于java - JEXL 2.1.1 - 表达式字符串中的大十进制文字导致解析错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13303841/