0

下面是伪代码

public void testImportInContext() {
    ParserContext ctx = new ParserContext();
    ctx.addImport("List", List.class);
    ctx.addImport("ArrayList", ArrayList.class);

    MVEL.eval("List test = null;User u =null", ctx);
}

发生异常

 - [Error: could not access: List; in class: org.mvel2.ParserContext]
 - [Near : {... List test = null;User u =null ....}]
4

1 回答 1

0

因为您只能在编译器中使用此功能。eval() 解释器不支持静态类型分析。eval 的第二个参数用于评估上下文对象。不是 ParserContext。

于 2013-01-24T13:34:38.257 回答