0
我想用多個屬性訪問器使用SPeL。Spring | SPEL多個屬性訪問器
StandardEvaluationContext simpleContext = new StandardEvaluationContext(myPojo);
simpleContext.setVariable("ctx", ruleExecutionContext);
simpleContext.setPropertyAccessors(Arrays.asList(new MapAccessor(), new ReflectivePropertyAccessor()));
ExpressionParser parser = new SpelExpressionParser();
return (Boolean) parser.parseExpression(spelExpression).getValue(simpleContext, RulebaseConfiguration.LIB_MAP);
RulebaseConfiguration.LIB_MAP包含{"instanceName": instance}
我想通過對實例可以在一個POJO操作表達式以及調用方法。但它只是將地圖帶入效果。
我得到這個錯誤:
SEVERE: Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.expression.spel.SpelEvaluationException: EL1008E: Property or field 'payload' cannot be found on object of type 'java.util.HashMap' - maybe not public?] with root cause
org.springframework.expression.spel.SpelEvaluationException: EL1008E: Property or field 'payload' cannot be found on object of type 'java.util.HashMap' - maybe not public?
at org.springframework.expression.spel.ast.PropertyOrFieldReference.readProperty(PropertyOrFieldReference.java:226)
你需要證明你的表情,你正在做什麼。 'getValue(ctx,rootObject)'覆蓋傳入上下文的ctor的'rootObject'。 –
表達式:'payload ['nationality'] =='GBR'' MyPojo(根對象)有一個稱爲有效載荷的映射。 – user1189332
在其他一些情況下,我也會有這樣一個表達式:'payload ['channel'] == nationalityLookup.resolveChannel('CBR1000')' – user1189332