Apache Commons JEXL

盖昊东
2023-12-01

Apache Commons JEXL

JEXL is a library intended to facilitate the implementation of dynamic and scripting features in applications and frameworks written in Java.

example:

import org.apache.commons.jexl3.*;

public class MyJEXL {

    public static void main(String[] args) {

        JexlEngine jexl = new JexlBuilder().create();

        String jexlExp = "person.getName()";

        JexlExpression jexlExpression = jexl.createExpression(jexlExp);

        JexlContext jexlContext = new MapContext();

        Person person = new Person("aaa", "20");
        jexlContext.set("person", person);

        Object o = jexlExpression.evaluate(jexlContext);

        System.out.println(o);
    }
}

pom.xml

 <dependencies>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-jexl3</artifactId>
            <version>3.0</version>
        </dependency>
    </dependencies>
 类似资料:

相关阅读

相关文章

相关问答