Mvel异常无法解析的属性或标识符

时间:2018-10-17 13:12:18

标签: mvel

`

当Mvel表达式键中包含空格时,我将得到错误提示

Map<String, Object> input = new HashMap<String, Object>();
input.put("na me", "prachi");
input.put("prid", 10);

final String expression = "(na me == \"prachi\") && (prid > 5 && prid < 20)";
System.out.println("Mvel output "+MVEL.evalToBoolean(expression, input ));

Error: Exception in thread "main" [Error: unresolvable property or identifier: na]
[Near : {... (na me == "prachi") && (price>1 ....}]
          ^
[Line: 1, Column: 2]
at org.mvel2.PropertyAccessor.getBeanProperty(PropertyAccessor.java:676)
at org.mvel2.PropertyAccessor.getNormal(PropertyAccessor.java:178)
at org.mvel2.PropertyAccessor.get(PropertyAccessor.java:145)
at org.mvel2.PropertyAccessor.get(PropertyAccessor.java:125)
at org.mvel2.ast.ASTNode.getReducedValue(ASTNode.java:187)
at org.mvel2.MVELInterpretedRuntime.parseAndExecuteInterpreted(MVELInterpretedRuntime.java:101)
at org.mvel2.MVELInterpretedRuntime.parse(MVELInterpretedRuntime.java:47)`

0 个答案:

没有答案