Apache Commons JEXL

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>
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章